Building Java (micro)services for the Cloud 
The DHARMA principles 
&& 
Chuck Norris Doesn’t Need DevOps… 
but Java Developers might benefit 
Daniel Bryant 
Principal Consultant, Open Credo 
daniel.bryant@opencredo.com 
@danielbryantuk
Who Am I? 
• Principal Consultant at OpenCredo 
• LJC Associate 
 Agile transformations 
 DevOps, Cloud and Microservices 
 Big Data 
• Adopt OpenJDK and JSR 
10/11/2014 @danielbryantuk
The Current Industry Wish List… 
• Service-Oriented Architecture 
• Cloud-based deployments 
• DevOps Culture 
10/11/2014 @danielbryantuk
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) 
10/11/2014 @danielbryantuk
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
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 understanding 
the new architecture 
10/11/2014 @danielbryantuk
Not testing in the Cloud… 
(hint: here be dragons!) 
10/11/2014 @danielbryantuk
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
Create a PACT 
10/11/2014 @danielbryantuk 
github.com/DiUS/pact-jvm
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 
www.codingthearchitecture.com/2014/07/06/distributed_big_balls_of_mud.html 
10/11/2014 @danielbryantuk
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
Circuit-breaker/bulkhead 
10/11/2014 @danielbryantuk 
github.com/Netflix/Hystrix 
projects.spring.io/spring-cloud/
Antifragile Patterns: Elastic Scaling 
Stateless components 
Distributed data stores / caches 
10/11/2014 @danielbryantuk
Microservices in the Cloud… 
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
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 
The rest of us… 
…work in teams to develop software 
10/11/2014 @danielbryantuk
Software Development Teams 
• Developers 
• Quality Assurance 
• Operations 
10/11/2014 @danielbryantuk
Software Development Teams 
• Developers 
• Quality Assurance 
• Operations 
10/11/2014 @danielbryantuk
10/11/2014 @danielbryantuk
Software Development Teams 
• Developers 
• Quality Assurance 
• Operations 
10/11/2014 @danielbryantuk
10/11/2014 @danielbryantuk
Software Development Teams 
• Developers 
• Quality Assurance 
• Operations 
10/11/2014 @danielbryantuk
10/11/2014 @danielbryantuk
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) 
The rest of us… 
…need high-quality automated QA 
10/11/2014 @danielbryantuk
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 
The rest of us… 
…should manage our resources and 
cultivate ‘mechanical sympathy’ 
10/11/2014 @danielbryantuk
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 
The rest of us… 
…should log all errors (and other vital 
information for diagnostic purposes) 
10/11/2014 @danielbryantuk
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 
blog.comperiosearch.com/blog/2014/08/14/elk-one-vagrant-box 
10/11/2014 @danielbryantuk
“…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? 
– daniel.bryant@opencredo.com 
– @danielbryantuk 
10/11/2014 @danielbryantuk

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

  • 1.
    Building Java (micro)servicesfor the Cloud The DHARMA principles && Chuck Norris Doesn’t Need DevOps… but Java Developers might benefit Daniel Bryant Principal Consultant, Open Credo daniel.bryant@opencredo.com @danielbryantuk
  • 2.
    Who Am I? • Principal Consultant at OpenCredo • LJC Associate  Agile transformations  DevOps, Cloud and Microservices  Big Data • Adopt OpenJDK and JSR 10/11/2014 @danielbryantuk
  • 3.
    The Current IndustryWish List… • Service-Oriented Architecture • Cloud-based deployments • DevOps Culture 10/11/2014 @danielbryantuk
  • 4.
    The Current IndustryWish 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) 10/11/2014 @danielbryantuk
  • 5.
    So, what’s allthis I hear about small services?… 10/11/2014 @danielbryantuk
  • 6.
    “Microservices”aka • “SOAdone 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
  • 7.
    “Can I fitthe service in my head?” 10/11/2014 @danielbryantuk
  • 8.
    Moving to theCloud – common problems… 10/11/2014 @danielbryantuk
  • 9.
    Not respecting theunderlying environment 10/11/2014 @danielbryantuk
  • 10.
    Lack of application/platformmonitoring… 10/11/2014 @danielbryantuk
  • 11.
    Bizarre failure modes… 10/11/2014 @danielbryantuk
  • 12.
    Difficulty in understanding the new architecture 10/11/2014 @danielbryantuk
  • 13.
    Not testing inthe Cloud… (hint: here be dragons!) 10/11/2014 @danielbryantuk
  • 14.
    We’ve created the“Cloud DHARMA Principles” to act as a checklist when building Cloud apps 10/11/2014 @danielbryantuk
  • 15.
    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
  • 16.
    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
  • 17.
    API Docs withSwagger 10/11/2014 @danielbryantuk helloreverb.com/developers/swagger
  • 18.
    Create a PACT 10/11/2014 @danielbryantuk github.com/DiUS/pact-jvm
  • 19.
    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
  • 20.
    High Cohesion /Loose Coupling (all the way down…) • Code • Architecture – Components – Services • Public API – PayPal (bit.ly/1hnZNly) 10/11/2014 @danielbryantuk
  • 21.
    Microservices: Architectural SilverBullet? • 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
  • 22.
    No!! It’s alltoo easy to… 1) Create a distributed monolith 2) Push complexity into orchestration www.codingthearchitecture.com/2014/07/06/distributed_big_balls_of_mud.html 10/11/2014 @danielbryantuk
  • 23.
  • 24.
    Sneak-peak: Smashing theMonolith… • 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
  • 25.
    DZone’s Enterprise IntegrationGuide 10/11/2014 @danielbryantuk www.dzone.com/page/research
  • 26.
    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
  • 27.
    Thou Shalt Knowthy 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
  • 28.
    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
  • 29.
    Antifragile • Theopposite of fragile? – Robust… – Antifragile… • Netflix are best-in-class – bit.ly/1gs5n3q • System must be robust first! 10/11/2014 @danielbryantuk
  • 30.
    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
  • 31.
    Retries 10/11/2014 @danielbryantuk github.com/rholder/guava-retrying
  • 32.
    Circuit-breaker/bulkhead 10/11/2014 @danielbryantuk github.com/Netflix/Hystrix projects.spring.io/spring-cloud/
  • 33.
    Antifragile Patterns: ElasticScaling Stateless components Distributed data stores / caches 10/11/2014 @danielbryantuk
  • 34.
    Microservices in theCloud… 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
  • 35.
    and now toDevOps… …or as the recruiters like to say “DeeVoips”, “DevAnOps” and “Dev-Oops” 10/11/2014 @danielbryantuk
  • 36.
    What’s in aName? • “Development / Operations” • Increasing cohesion between: – Business – Development – Quality Assurance – Operations “Bu-Dev-Qa-Ops”? 10/11/2014 @danielbryantuk
  • 37.
    So, What’s ChuckNorris Doing Here? 10/11/2014 @danielbryantuk
  • 38.
    Chuck Norris doesn’tneed DevOps… …as a one-man army he codes with one hand, tests with the other and deploys with his beard The rest of us… …work in teams to develop software 10/11/2014 @danielbryantuk
  • 39.
    Software Development Teams • Developers • Quality Assurance • Operations 10/11/2014 @danielbryantuk
  • 40.
    Software Development Teams • Developers • Quality Assurance • Operations 10/11/2014 @danielbryantuk
  • 41.
  • 42.
    Software Development Teams • Developers • Quality Assurance • Operations 10/11/2014 @danielbryantuk
  • 43.
  • 44.
    Software Development Teams • Developers • Quality Assurance • Operations 10/11/2014 @danielbryantuk
  • 45.
  • 46.
    This silo mentalityhas to stop 10/11/2014 @danielbryantuk
  • 47.
    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
  • 48.
    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
  • 49.
    Chuck Norris doesn’tdo QA… …Chuck Norris can test an entire application with a single assert (and get 110% code coverage) The rest of us… …need high-quality automated QA 10/11/2014 @danielbryantuk
  • 50.
    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
  • 51.
    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
  • 52.
    All arrays ChuckNorris creates are of infinite size… …as Chuck Norris knows no bounds The rest of us… …should manage our resources and cultivate ‘mechanical sympathy’ 10/11/2014 @danielbryantuk
  • 53.
    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
  • 54.
    When Chuck Norristhrows Exceptions… …everybody knows about it because they land outside of the data center The rest of us… …should log all errors (and other vital information for diagnostic purposes) 10/11/2014 @danielbryantuk
  • 55.
    Monitor All TheThings! • Infrastructure monitoring – Nagios / Zabbix – Codahale, Actuator • Distributed Tracing – twitter.github.io/zipkin • Centralised Logging – logstash.net 10/11/2014 @danielbryantuk
  • 56.
    The ‘ELK’ Stack blog.comperiosearch.com/blog/2014/08/14/elk-one-vagrant-box 10/11/2014 @danielbryantuk
  • 57.
    “…but what shouldI graph?” 10/11/2014 @danielbryantuk
  • 58.
  • 59.
  • 60.
    Thanks For Listening • Massive thanks – OpenCredo (@OpenCredo) – notonthehighstreet.com – RecWorks & The LJC • Questions / comments? – daniel.bryant@opencredo.com – @danielbryantuk 10/11/2014 @danielbryantuk

Editor's Notes

  • #48 organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations Focus on flow: translate business ideas to a working service efficiently by examining how fast artifacts and work flows through the development lifecycle Amplify feedback loops: quickly learn about the system by seeing through fast feedback on what happens to results of changes
  • #51 James Gough’s “The benefits are more than just the tests” Mash Badar’s “TDD at Scale” (slidesha.re/19P7kzS)