ljc mashup "building java microservices for the cloud && chuck norris doesn't need...

60
Building Java (micro)services for the Cloud The DHARMA principles Daniel Bryant Principal Consultant, Open Credo [email protected] @danielbryantuk && Chuck Norris Doesn’t Need DevOps… but Java Developers might benefit

Upload: daniel-bryant

Post on 02-Jul-2015

799 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Building Java (micro)services for the CloudThe DHARMA principles

Daniel BryantPrincipal Consultant, Open Credo

[email protected]@danielbryantuk

&&

Chuck Norris Doesn’t Need DevOps…but Java Developers might benefit

Page 2: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Who Am I?

• LJC Associate

• Adopt OpenJDK and JSR

10/11/2014 @danielbryantuk

• Principal Consultant at OpenCredo

Agile transformations

DevOps, Cloud and Microservices

Big Data

Page 3: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

The Current Industry Wish List…

• Service-Oriented Architecture

• Cloud-based deployments

• DevOps Culture

@danielbryantuk10/11/2014

Page 4: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

The Current Industry Wish List…

• Service-Oriented Architecture– muCon 2014 (coming soon via skillsmatter.com)

• Cloud-based deployments– JavaOne 2014 (coming soon via parleys.com)

• DevOps Culture– Devoxx UK talk (bit.ly/1BylnZb)

– Previous LJC Event (bit.ly/1elVPJz)

@danielbryantuk10/11/2014

Page 5: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

So, what’s all this I hear about small services?…

10/11/2014 @danielbryantuk

Page 6: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

“Microservices”aka

• “SOA done right”

• “SRP” services– “Java, The Unix Way” (bit.ly/1cX8VsS)

• “Small” codebase services – 1000 LOC… 100… 10…?

• “12 Factor apps” (12factor.net)

• My personal opinion…

10/11/2014 @danielbryantuk

Page 7: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

“Can I fit the service in my head?”

10/11/2014 @danielbryantuk

Page 8: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Moving to the Cloud – common problems…

10/11/2014 @danielbryantuk

Page 9: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

Not respecting the underlying environment

Page 10: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

Lack of application/platform monitoring…

Page 11: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

Bizarre failure modes…

Page 12: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

Difficulty in understandingthe new architecture

Page 13: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

Not testing in the Cloud…(hint: here be dragons!)

Page 14: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

We’ve created the “Cloud DHARMA Principles” to act as a checklist when building Cloud apps

10/11/2014 @danielbryantuk

Page 15: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Documented (just enough)

Highly cohesive/loosely coupled (all the way down)

Automated from commit to Cloud

Resource aware

Monitored thoroughly

Antifragile

10/11/2014 @danielbryantuk

Page 16: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Documented (just enough)

Highly cohesive/loosely coupled (all the way down)

Automated from commit to Cloud

Resource aware

Monitored thoroughly

Antifragile

10/11/2014 @danielbryantuk

Page 17: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

API Docs with Swagger

10/11/2014 @danielbryantuk

helloreverb.com/developers/swagger

Page 18: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Create a PACT

10/11/2014 @danielbryantuk

github.com/DiUS/pact-jvm

Page 19: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Documented (just enough)

Highly cohesive/loosely coupled (all the way down)

Automated from commit to Cloud

Resource aware

Monitored thoroughly

Antifragile

10/11/2014 @danielbryantuk

Page 20: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

High Cohesion / Loose Coupling(all the way down…)

• Code

• Architecture– Components

– Services

• Public API– PayPal (bit.ly/1hnZNly)

10/11/2014 @danielbryantuk

Page 21: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Microservices: Architectural Silver Bullet?

• Enforce service boundaries– Bounded contexts

– Domain-Driven Design

• Separation of Concerns– Encapsulate what varies

– Easier to scale/tune independently

• Is this a free-lunch? (bit.ly/1gSw4L7)

10/11/2014 @danielbryantuk

Page 22: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

No!! It’s all too easy to…

1) Create a distributed monolith

2) Push complexity into orchestration

10/11/2014 @danielbryantuk

www.codingthearchitecture.com/2014/07/06/distributed_big_balls_of_mud.html

Page 23: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

Page 24: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Sneak-peak: Smashing the Monolith…

• Business functionality -“Cart Service”– Noun, verb, SRP (slidesha.re/1owdJhh)

• Technology chunk - “Email Service”

• Vertical Slice - “Service per page” – Groupon (vimeo.com/105880150)

• Horizontal Slice - “User Repo” – An anti-pattern?

10/11/2014 @danielbryantuk

Page 25: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

DZone’s Enterprise Integration Guide

10/11/2014 @danielbryantuk

www.dzone.com/page/research

Page 26: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Documented (just enough)

Highly cohesive/loosely coupled (all the way down)

Automated from commit to Cloud

Resource aware

Monitored thoroughly

Antifragile

10/11/2014 @danielbryantuk

Page 27: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Thou Shalt Know thy Cloud…

“Everything fails all the time [in the cloud]”

Werner Vogels, CTO, Amazon.com

• Everything is ephemeral

• Volatility

• Noisy (virtual) neighbours– bit.ly/1w1HQy7

10/11/2014 @danielbryantuk

Page 28: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Documented (just enough)

Highly cohesive/loosely coupled (all the way down)

Automated from commit to Cloud

Resource aware

Monitored thoroughly

Antifragile

10/11/2014 @danielbryantuk

Page 29: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Antifragile

• The opposite of fragile?

– Robust…

– Antifragile…

• Netflix are best-in-class

– bit.ly/1gs5n3q

• System must be robust first!

10/11/2014 @danielbryantuk

Page 30: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Design for Failure

• Distributed Computing Principles

– ‘For young bloods’ (bit.ly/1pKVepz)

– Eight Fallacies… (bit.ly/1zCBet7)

• Design patterns

– Timeouts / retries

– Bulkheads / circuit-breakers

10/11/2014 @danielbryantuk

Page 31: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Retries

10/11/2014 @danielbryantuk

github.com/rholder/guava-retrying

Page 32: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

github.com/Netflix/Hystrixprojects.spring.io/spring-cloud/

Circuit-breaker/bulkhead

Page 33: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Antifragile Patterns: Elastic Scaling

Stateless components

Distributed data stores / caches

10/11/2014 @danielbryantuk

Page 34: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Documented (just enough)

Highly cohesive/loosely coupled (all the way down)

Automated from commit to Cloud

Resource aware

Monitored thoroughly

Antifragile

10/11/2014 @danielbryantuk

Microservices in the Cloud…

Page 35: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

and now to DevOps…

…or as the recruiters like to say

“DeeVoips”, “DevAnOps” and “Dev-Oops”

10/11/2014 @danielbryantuk

Page 36: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

What’s in a Name?

• “Development / Operations”

• Increasing cohesion between:– Business

– Development

– Quality Assurance

– Operations

“Bu-Dev-Qa-Ops”?

10/11/2014 @danielbryantuk

Page 37: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

So, What’s Chuck Norris Doing Here?

10/11/2014 @danielbryantuk

Page 38: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Chuck Norris doesn’t need DevOps…

…as a one-man army he codes with one hand, tests with the other and deploys with his beard

10/11/2014 @danielbryantuk

The rest of us…

…work in teams to develop software

Page 39: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Software Development Teams

• Developers

• Quality Assurance

• Operations

@danielbryantuk10/11/2014

Page 40: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Software Development Teams

• Developers

• Quality Assurance

• Operations

@danielbryantuk10/11/2014

Page 41: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

@danielbryantuk10/11/2014

Page 42: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Software Development Teams

• Developers

• Quality Assurance

• Operations

@danielbryantuk10/11/2014

Page 43: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

@danielbryantuk10/11/2014

Page 44: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Software Development Teams

• Developers

• Quality Assurance

• Operations

@danielbryantuk10/11/2014

Page 45: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

@danielbryantuk10/11/2014

Page 46: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

This silo mentality has to stop

10/11/2014 @danielbryantuk

Page 47: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Culture is Vital

• Culture drives behaviour, drives culture…

– “Communication, simplicity, feedback, courage”

– Everyone is responsible for delivery

– Continuous experimentation and learning

• Not easy to change culture

– The hardest part of DevOps…

– …but you will learn new things

10/11/2014 @danielbryantuk

Page 48: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Changing Culture

• Create an effective team…

• “Habits of highly effective technical teams”

– Martijn Verburg (bit.ly/1aF9SnK)

• “Patterns of Effective Teams”

– Dan North (vimeo.com/68226771)

10/11/2014 @danielbryantuk

Page 49: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Chuck Norris doesn’t do QA…

…Chuck Norris can test an entire application with a single assert

(and get 110% code coverage)

10/11/2014 @danielbryantuk

The rest of us…

…need high-quality automated QA

Page 50: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Automating QA

• Intra-component integration testing

– Utilise embedded datastore/middleware

– Cucumber (via ports/adapters/API?)

• Fault-tolerance

– Chris Batey’s Skillscast (bit.ly/1tU6wZj)

– WireMock + Saboteur (wiremock.org)

– “Scassandra” (github.com/scassandra)

10/11/2014 @danielbryantuk

Page 51: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Automating QA

• Inter-component integration testing

– The hardest part of SOA…

– Consider ‘synthetic txns’ (active monitoring)

• Service virtualisation

– Mountebank (www.mbtest.org)

– Mock external services (e.g. Spring profiles)

10/11/2014 @danielbryantuk

Page 52: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

All arrays Chuck Norris creates are of infinite size…

…as Chuck Norris knows no bounds

10/11/2014 @danielbryantuk

The rest of us…

…should manage our resources and cultivate ‘mechanical sympathy’

Page 53: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Cultivating “Mechanical Sympathy”

• Virtualisation– Tech Target (bit.ly/1kDVqyG)

• Networking– ‘Unix and Linux System Administration Handbook’

– AWS docs aws.amazon.com/documentation

• Thinking/Acting Operationally– You write it, you run it… (“dev on call”)

10/11/2014 @danielbryantuk

Page 54: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

When Chuck Norris throws Exceptions…

…everybody knows about it because they land outside of the data center

10/11/2014 @danielbryantuk

The rest of us…

…should log all errors (and other vital information for diagnostic purposes)

Page 55: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Monitor All The Things!

• Infrastructure monitoring– Nagios / Zabbix

– Codahale, Actuator

• Distributed Tracing – twitter.github.io/zipkin

• Centralised Logging– logstash.net

10/11/2014 @danielbryantuk

Page 56: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

The ‘ELK’ Stack

10/11/2014 @danielbryantuk

blog.comperiosearch.com/blog/2014/08/14/elk-one-vagrant-box

Page 57: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

“…but what should I graph?”

10/11/2014 @danielbryantuk

Page 58: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

Phrase borrowed from Etsy!

Page 59: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

10/11/2014 @danielbryantuk

Page 60: LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't Need DevOps"

Thanks For Listening

• Massive thanks

– OpenCredo (@OpenCredo)

– notonthehighstreet.com

– RecWorks & The LJC

• Questions / comments?

[email protected]

– @danielbryantuk

10/11/2014 @danielbryantuk