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
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
The Current Industry Wish List…
• Service-Oriented Architecture
• Cloud-based deployments
• DevOps Culture
@danielbryantuk10/11/2014
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
So, what’s all this I hear about small services?…
10/11/2014 @danielbryantuk
“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
“Can I fit the service in my head?”
10/11/2014 @danielbryantuk
Moving to the Cloud – common problems…
10/11/2014 @danielbryantuk
10/11/2014 @danielbryantuk
Not respecting the underlying environment
10/11/2014 @danielbryantuk
Lack of application/platform monitoring…
10/11/2014 @danielbryantuk
Bizarre failure modes…
10/11/2014 @danielbryantuk
Difficulty in understandingthe new architecture
10/11/2014 @danielbryantuk
Not testing in the Cloud…(hint: here be dragons!)
We’ve created the “Cloud DHARMA Principles” to act as a checklist when building Cloud apps
10/11/2014 @danielbryantuk
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
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
API Docs with Swagger
10/11/2014 @danielbryantuk
helloreverb.com/developers/swagger
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
High Cohesion / Loose Coupling(all the way down…)
• Code
• Architecture– Components
– Services
• Public API– PayPal (bit.ly/1hnZNly)
10/11/2014 @danielbryantuk
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
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
10/11/2014 @danielbryantuk
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
DZone’s Enterprise Integration Guide
10/11/2014 @danielbryantuk
www.dzone.com/page/research
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
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
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
Antifragile
• The opposite of fragile?
– Robust…
– Antifragile…
• Netflix are best-in-class
– bit.ly/1gs5n3q
• System must be robust first!
10/11/2014 @danielbryantuk
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
Retries
10/11/2014 @danielbryantuk
github.com/rholder/guava-retrying
10/11/2014 @danielbryantuk
github.com/Netflix/Hystrixprojects.spring.io/spring-cloud/
Circuit-breaker/bulkhead
Antifragile Patterns: Elastic Scaling
Stateless components
Distributed data stores / caches
10/11/2014 @danielbryantuk
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…
and now to DevOps…
…or as the recruiters like to say
“DeeVoips”, “DevAnOps” and “Dev-Oops”
10/11/2014 @danielbryantuk
What’s in a Name?
• “Development / Operations”
• Increasing cohesion between:– Business
– Development
– Quality Assurance
– Operations
“Bu-Dev-Qa-Ops”?
10/11/2014 @danielbryantuk
So, What’s Chuck Norris Doing Here?
10/11/2014 @danielbryantuk
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
Software Development Teams
• Developers
• Quality Assurance
• Operations
@danielbryantuk10/11/2014
Software Development Teams
• Developers
• Quality Assurance
• Operations
@danielbryantuk10/11/2014
@danielbryantuk10/11/2014
Software Development Teams
• Developers
• Quality Assurance
• Operations
@danielbryantuk10/11/2014
@danielbryantuk10/11/2014
Software Development Teams
• Developers
• Quality Assurance
• Operations
@danielbryantuk10/11/2014
@danielbryantuk10/11/2014
This silo mentality has to stop
10/11/2014 @danielbryantuk
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
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
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
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
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
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’
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
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)
Monitor All The Things!
• Infrastructure monitoring– Nagios / Zabbix
– Codahale, Actuator
• Distributed Tracing – twitter.github.io/zipkin
• Centralised Logging– logstash.net
10/11/2014 @danielbryantuk
The ‘ELK’ Stack
10/11/2014 @danielbryantuk
blog.comperiosearch.com/blog/2014/08/14/elk-one-vagrant-box
“…but what should I graph?”
10/11/2014 @danielbryantuk
10/11/2014 @danielbryantuk
Phrase borrowed from Etsy!
10/11/2014 @danielbryantuk
Thanks For Listening
• Massive thanks
– OpenCredo (@OpenCredo)
– notonthehighstreet.com
– RecWorks & The LJC
• Questions / comments?
– @danielbryantuk
10/11/2014 @danielbryantuk
Top Related