SlideShare a Scribd company logo
1 of 69
Micro Services
                            Java, the Unix way




Thursday, 8 November 12
Watch the video with slide
                         synchronization on InfoQ.com!
                      http://www.infoq.com/presentations
                                /Micro-Services

       InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
  Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Presented at QCon San Francisco
                          www.qconsf.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
 - practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Principal Consultant

               Senior Engineer

            story teller




       @boicy             http://bovon.org   jalewis@thoughtworks.com
Thursday, 8 November 12
WHAT I DID LAST SUMMER
        Or how we designed and built a Resource Oriented,
        Event Driven System out of applications about 1000
        lines long…




Thursday, 8 November 12
In the beginning…
       • There was a new product being developed by
         an organisation in London

       • The organisation had gathered their list of
         high level requirements

       • And they asked ThoughtWorks if we could
         help them design and build it…


Thursday, 8 November 12
So we took a look at their
                               requirements

       • Me and my mates at ThoughtWorks

       • Worked out to be about a lot of points worth
         of User Stories




Thursday, 8 November 12
Complete




        Half way
        through




             0
                                                                     Heat
                   opened    End day   Cows     hell
                                                        pigs fly   death of
                   the box      1      come   freezes
                                                                     the
                                       home
                                                                   Universe




Thursday, 8 November 12
Tip 1

                              Divide and conquer


                    break	
  down	
  complex	
  problems	
  into	
  
                     smaller	
  chunks	
  that	
  can	
  be	
  solved	
  
                                   individually



Thursday, 8 November 12
Thursday, 8 November 12
Thursday, 8 November 12
heavy industrial




Thursday, 8 November 12
commercial




Thursday, 8 November 12
light residential



Thursday, 8 November 12
Each small box represents a capability,

                   composed of one or more services
                                                             13

Thursday, 8 November 12
And there were some, umm, interesting
           non-functional requirements too




Thursday, 8 November 12
1000TPS, 99th percentile latency of < 2
                   seconds

                                                             15

Thursday, 8 November 12
Support a user base of 100 million active
                   customers

                                                               16

Thursday, 8 November 12
Support bulk loads of 30 – 90 million records
                   nightly and keep them for six months
                   (16,200,000,000 records)
                                                               17

Thursday, 8 November 12
Did I mention PCI Level 1?




                                                       18

Thursday, 8 November 12
Finally, this is a product build.

                           So it needed to be modular /
                          <cough> “infinitely configurable”




Thursday, 8 November 12
The product need to to be…
       • Performant
             – fairly high throughput both transactional and batch
       • Fault tolerant
             – One thing about the cloud, you are designing for failure right?
       • Configurable
             – On a per install or SaaS basis
       • Portable
             – Fortunately not to Windows…
       • Maintainable
             – over multiple versions and years
       • Supporting big data sets
             – Billions of transactions available
             – Millions of customers available




Thursday, 8 November 12
Plus ça change, plus c'est la même chose.



              (The	
  more	
  things	
  change	
  the	
  more	
  they	
  stay	
  the	
  same)




Thursday, 8 November 12
• The only way we could hit anything like the
         timescales required was to scale the
         programme quickly

       • And that meant multiple teams in multiple
         workstreams




Thursday, 8 November 12
So, after five weeks we had broken the problem down into capabilties




           Now we had to start scaling the teams to deliver these capabilities

Thursday, 8 November 12
Tip 2

          Use Conway’s Law to structure teams

            “…organiza>ons	
  which	
  design	
  systems	
  …	
  are	
  constrained	
  to	
  produce	
  designs
            which	
  are	
  copies	
  of	
  the	
  communica>on	
  structure	
  of	
  those	
  organiza>ons”
              Melvin	
  Conway,	
  1968




Thursday, 8 November 12
The first business capability - Users
       • Responsible for creation and maintenance of users
         in the system
             – Up to 100 million of them per instance of the product

       • Used by many clients with many usage patterns
             – Call centre and website – CRUD
             – Inbound batch files – CRUD x hundreds of thousands per
               night

       • Many downstream consumers of the data
             – Fulfilment systems for example




Thursday, 8 November 12
Tip 3


                          The Last Responsible Moment



         Don’t decide everything at the point you know least




Thursday, 8 November 12
We started with a business process…




                    and noticed something funny…
Thursday, 8 November 12
events...




                                      28

Thursday, 8 November 12
* Dan North coined the term Enterprise Night Bus…




      ESB*
              I know what you are thinking…


Thursday, 8 November 12
Or you could use the web




Thursday, 8 November 12
Tip 4



                     Be of the web, not behind the web




Thursday, 8 November 12
RFC 5023 to be precise
Thursday, 8 November 12
Our Users                       /user-request


Capability
                                                application/atom+json

                          /user-request/1223




                                                                        33

Thursday, 8 November 12
Our Users                                   /user-request


Capability
                                                            application/atom+json

                                      /user-request/1223




                          Standard resource representations using well known
                          web standards – atom+json



                                                                                    34

Thursday, 8 November 12
Our Users                                  /user-request


Capability
                                                           application/atom+json

                                     /user-request/1223




                          Reified the request to create a user. Clients POST
                          a request to create a user as an entry to an atom
                          collection.


                                                                                   35

Thursday, 8 November 12
Tip 5

                   If something is important, make it an
                   explicit part of your design


                          Reify
                          to convert into or regard as a concrete thing: to reify a
                          concept.




Thursday, 8 November 12
Our Users                                    /user-request


Capability
                                                             application/atom+json

                                       /user-request/1223




                          Event queue has the single responsibility of
                          managing state transitions for the request to
                          create a user

                                                                                     37

Thursday, 8 November 12
Our Users                                        /user-request


Capability
                                                                 application/atom+json

                                           /user-request/1223




                          Queue Processing Engine implemented the Competing
                          Consumer pattern using Conditional GET, PUT and Etags
                          against the atom collection exposed by the event queue

                                                                                         38

Thursday, 8 November 12
Our Users                                        /user-request


Capability
                                                                 application/atom+json

                                           /user-request/1223




                          User Service and store is the system of record for
                          users


                                                                                         39

Thursday, 8 November 12
Our Users                 After creation, representations of Users are available
                                             /user-request
                          at canonical locations in well defined formats and
Capability                creation events added to another atomapplication/atom+json
                                         /user-request/1223
                                                                 collection




                                               /users/142       application/vnd.user+JSON




                                                 /users

                                                                                        40

Thursday, 8 November 12
Where they are available
            for consumption by other
              downstream systems




Thursday, 8 November 12
Reporting capability polls for new
                                                     user events




            Fulfilment capability polls for new
                          user events


Thursday, 8 November 12
Our micro-services
       • User Request Queue
             –Forms the transactional boundary of the system

       • Request Queue Processor
             –Competing Consumer processes events on the
              queue and POSTs them to

       • User Service
             –System of record for Users in the system
             –Responsible for all state changes of those users
             –Exposes events on those users to other systems


Thursday, 8 November 12
CHARACTERISTICS OF MICRO-
            SERVICES


Thursday, 8 November 12
Small with a single responsibility
       • Each application only does one thing

       • Small enough to fit in your head
             –James’ heuristic
             –“If a class is bigger than my head then it is too big”


       • Small enough that you can throw them away
             –Rewrite over Maintain




Thursday, 8 November 12
Containerless and installed as well
                 behaved Unix services
       • Embedded web container
             – Jetty / SimpleWeb
             – This has a lot of benefits for testing (inproctester for example)
               and eases deployment

       • Packaged as a single executable jar
             – Along with their configuration
             – And unix standard rc.d scripts

       • Installed in the same way you would install httpd or any
         other application
             – Why recreate the wheel? Daemons seem to work ok for
               everything else. Unless you are *special*?



Thursday, 8 November 12
Located in different VCS roots
       • Each application is completely separate

       • Software developers see similarities and abstractions
             – And before you know it you have One Domain To Rule Them All

       • Domain Driven Design / Conways Law
             – Domains in different bounded contexts should be distinct – and its ok to have
               duplication
             – Use physical separation to enforce this

       • There will be common code, but it should be library and infrastructure
         code
             – Treat it as you would any other open source library
             – Stick it in a nexus repo somewhere and treat it as a binary dependency




Thursday, 8 November 12
Provisioned automatically
       • The way to manage the complexity of many
         small applications is declarative provisioning
             –UAT:
                   • 2 * service A, Load Balanced, Auto-Scaled
                   • 2 * service B, Load Balanced, Auto-Scaled
                   • 1 * database cluster




Thursday, 8 November 12
Status aware and auto-scaling
       • What good is competing consumer if you only
         have one consumer?
             –We don’t want to wake Laura up at three in the
              morning any more to start a new process

       • Use watchdog processes to monitor in-app
         status pages
             –Each app exposes metrics about itself
             –In our case, queue-depth for example
             –This allows others services to auto-scale to meet
              throughput requirements



Thursday, 8 November 12
A single capability composed
              of many small applications
                and exposing a uniform
             interface of Atom Collections




Thursday, 8 November 12
How the
                      capabilities form
                         a product


Thursday, 8 November 12
They interact via the web’s uniform
                        interface
       • HTTP
             – Don’t fight the battles already won
             – Use no-brainer force multipliers like reverse proxies

       • HATEOAS
             – Link relations drive state changes
             – Its an anti-corruption layer that allows the capability to evolve
               independently of its clients

       • Standard media types
             – Can be used by many different clients
             – You can monitor it using a feed reader if you want
             – and it makes your QA’s lives a *lot* easier


Thursday, 8 November 12
Capabilities poll each other for events, forming an eventually
                                          consistent system of systems

                                                                                             atom+json / HTTP (AJOH)


                                  Monitoring                        Reporting
                                  Capability                        Capability




                                                    (AJOH)                       (AJOH)
                          atom+XML / HTTP




                                                 User                            Fulfilment
                                               Capability                        Capability
                                                                    (AJOH)




                                                        (AJOH)                                (AJOH)




                              Inbound Batch           Call Centre

                                                                                 External
                                                                                 Suppliers




Thursday, 8 November 12
Tip 6


        Favour	
  service	
  choreography	
  over	
  orchestra>on




Thursday, 8 November 12
Each is decoupled from it’s clients. scalable, testable and
                                               deployable individually

                                                                                             atom+json / HTTP (AJOH)


                                  Monitoring                        Reporting
                                  Capability                        Capability




                                                    (AJOH)                       (AJOH)
                          atom+XML / HTTP




                                                 User                            Fulfilment
                                               Capability                        Capability
                                                                    (AJOH)




                                                        (AJOH)                                (AJOH)




                              Inbound Batch           Call Centre

                                                                                 External
                                                                                 Suppliers




Thursday, 8 November 12
Tip 7


    Use hypermedia controls to decouple services




Thursday, 8 November 12
Each developed by a separate team, using whatever tech they
                                                                    choose

                                                                                             atom+json / HTTP (AJOH)


                                  Monitoring                        Reporting
                                  Capability                        Capability




                                                    (AJOH)                       (AJOH)
                          atom+XML / HTTP




                                                 User                            Fulfilment
                                               Capability                        Capability
                                                                    (AJOH)




                                                        (AJOH)                                (AJOH)




                              Inbound Batch           Call Centre

                                                                                 External
                                                                                 Suppliers




Thursday, 8 November 12
Our stack
       • Embedded Jetty (current project uses SimpleWeb)

       • PicoContainer for DI

       • Hibernate (but wrote our own SQL)

       • Abdera for Atom

       • Smoothie charts

       • Metrics @codahale

       • Graphite


Thursday, 8 November 12
Tip 8



                          Make it easy to do the right thing and
                              hard to do the wrong thing


                  use tooling and architectural tests to
                       make complex tasks simple


Thursday, 8 November 12
Infrastructure automation stack
       • Fabric with boto

       • AWS, but deployable to anything with SSH

       • Maven (boo)

       • Git

       • Puppet for provisioning


Thursday, 8 November 12
NO SILVER BULLETS



Thursday, 8 November 12
this was hard to do well
       • We haven’t even talked about
             – Versioning
             – Integration
             – Testing
             – Deployment

       • Eventual Consistency can be tricky for people to get there
         head around

       • Developers like using enterprisy software
             – No one got fired for choosing an ESB
             – Convincing people to use the web is hard




Thursday, 8 November 12
SUMMARY



Thursday, 8 November 12
The Unix Philosophy               :s/pipes/hKp/	
  
  Lions commentary on Unix 2nd edition

Thursday, 8 November 12
Consistent and reinforcing practices
       Hexagonal Business capabilities composed of:

       Micro Services that you can

       Rewrite rather than maintain and which form

       A Distributed Bounded Context.

       Deployed as containerless OS services

       With standardised application protocols and message semantics

       Which are auto-scaling and designed for failure


Thursday, 8 November 12
Tip 9



                          Always have ten tips




Thursday, 8 November 12
Thanks!



                                                 @boicy
                                        http://bovon.org
                              jalewis@thoughtworks.com

Thursday, 8 November 12

More Related Content

More from C4Media

Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsC4Media
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechC4Media
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/awaitC4Media
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaC4Media
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayC4Media
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?C4Media
 
CockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseCockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseC4Media
 

More from C4Media (20)

Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery Teams
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in Adtech
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven Utopia
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?
 
CockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseCockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL Database
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Micro Services: Java, the Unix Way

  • 1. Micro Services Java, the Unix way Thursday, 8 November 12
  • 2. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /Micro-Services InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month
  • 3. Presented at QCon San Francisco www.qconsf.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. Principal Consultant Senior Engineer story teller @boicy http://bovon.org jalewis@thoughtworks.com Thursday, 8 November 12
  • 5. WHAT I DID LAST SUMMER Or how we designed and built a Resource Oriented, Event Driven System out of applications about 1000 lines long… Thursday, 8 November 12
  • 6. In the beginning… • There was a new product being developed by an organisation in London • The organisation had gathered their list of high level requirements • And they asked ThoughtWorks if we could help them design and build it… Thursday, 8 November 12
  • 7. So we took a look at their requirements • Me and my mates at ThoughtWorks • Worked out to be about a lot of points worth of User Stories Thursday, 8 November 12
  • 8. Complete Half way through 0 Heat opened End day Cows hell pigs fly death of the box 1 come freezes the home Universe Thursday, 8 November 12
  • 9. Tip 1 Divide and conquer break  down  complex  problems  into   smaller  chunks  that  can  be  solved   individually Thursday, 8 November 12
  • 15. Each small box represents a capability, composed of one or more services 13 Thursday, 8 November 12
  • 16. And there were some, umm, interesting non-functional requirements too Thursday, 8 November 12
  • 17. 1000TPS, 99th percentile latency of < 2 seconds 15 Thursday, 8 November 12
  • 18. Support a user base of 100 million active customers 16 Thursday, 8 November 12
  • 19. Support bulk loads of 30 – 90 million records nightly and keep them for six months (16,200,000,000 records) 17 Thursday, 8 November 12
  • 20. Did I mention PCI Level 1? 18 Thursday, 8 November 12
  • 21. Finally, this is a product build. So it needed to be modular / <cough> “infinitely configurable” Thursday, 8 November 12
  • 22. The product need to to be… • Performant – fairly high throughput both transactional and batch • Fault tolerant – One thing about the cloud, you are designing for failure right? • Configurable – On a per install or SaaS basis • Portable – Fortunately not to Windows… • Maintainable – over multiple versions and years • Supporting big data sets – Billions of transactions available – Millions of customers available Thursday, 8 November 12
  • 23. Plus ça change, plus c'est la même chose. (The  more  things  change  the  more  they  stay  the  same) Thursday, 8 November 12
  • 24. • The only way we could hit anything like the timescales required was to scale the programme quickly • And that meant multiple teams in multiple workstreams Thursday, 8 November 12
  • 25. So, after five weeks we had broken the problem down into capabilties Now we had to start scaling the teams to deliver these capabilities Thursday, 8 November 12
  • 26. Tip 2 Use Conway’s Law to structure teams “…organiza>ons  which  design  systems  …  are  constrained  to  produce  designs which  are  copies  of  the  communica>on  structure  of  those  organiza>ons” Melvin  Conway,  1968 Thursday, 8 November 12
  • 27. The first business capability - Users • Responsible for creation and maintenance of users in the system – Up to 100 million of them per instance of the product • Used by many clients with many usage patterns – Call centre and website – CRUD – Inbound batch files – CRUD x hundreds of thousands per night • Many downstream consumers of the data – Fulfilment systems for example Thursday, 8 November 12
  • 28. Tip 3 The Last Responsible Moment Don’t decide everything at the point you know least Thursday, 8 November 12
  • 29. We started with a business process… and noticed something funny… Thursday, 8 November 12
  • 30. events... 28 Thursday, 8 November 12
  • 31. * Dan North coined the term Enterprise Night Bus… ESB* I know what you are thinking… Thursday, 8 November 12
  • 32. Or you could use the web Thursday, 8 November 12
  • 33. Tip 4 Be of the web, not behind the web Thursday, 8 November 12
  • 34. RFC 5023 to be precise Thursday, 8 November 12
  • 35. Our Users /user-request Capability application/atom+json /user-request/1223 33 Thursday, 8 November 12
  • 36. Our Users /user-request Capability application/atom+json /user-request/1223 Standard resource representations using well known web standards – atom+json 34 Thursday, 8 November 12
  • 37. Our Users /user-request Capability application/atom+json /user-request/1223 Reified the request to create a user. Clients POST a request to create a user as an entry to an atom collection. 35 Thursday, 8 November 12
  • 38. Tip 5 If something is important, make it an explicit part of your design Reify to convert into or regard as a concrete thing: to reify a concept. Thursday, 8 November 12
  • 39. Our Users /user-request Capability application/atom+json /user-request/1223 Event queue has the single responsibility of managing state transitions for the request to create a user 37 Thursday, 8 November 12
  • 40. Our Users /user-request Capability application/atom+json /user-request/1223 Queue Processing Engine implemented the Competing Consumer pattern using Conditional GET, PUT and Etags against the atom collection exposed by the event queue 38 Thursday, 8 November 12
  • 41. Our Users /user-request Capability application/atom+json /user-request/1223 User Service and store is the system of record for users 39 Thursday, 8 November 12
  • 42. Our Users After creation, representations of Users are available /user-request at canonical locations in well defined formats and Capability creation events added to another atomapplication/atom+json /user-request/1223 collection /users/142 application/vnd.user+JSON /users 40 Thursday, 8 November 12
  • 43. Where they are available for consumption by other downstream systems Thursday, 8 November 12
  • 44. Reporting capability polls for new user events Fulfilment capability polls for new user events Thursday, 8 November 12
  • 45. Our micro-services • User Request Queue –Forms the transactional boundary of the system • Request Queue Processor –Competing Consumer processes events on the queue and POSTs them to • User Service –System of record for Users in the system –Responsible for all state changes of those users –Exposes events on those users to other systems Thursday, 8 November 12
  • 46. CHARACTERISTICS OF MICRO- SERVICES Thursday, 8 November 12
  • 47. Small with a single responsibility • Each application only does one thing • Small enough to fit in your head –James’ heuristic –“If a class is bigger than my head then it is too big” • Small enough that you can throw them away –Rewrite over Maintain Thursday, 8 November 12
  • 48. Containerless and installed as well behaved Unix services • Embedded web container – Jetty / SimpleWeb – This has a lot of benefits for testing (inproctester for example) and eases deployment • Packaged as a single executable jar – Along with their configuration – And unix standard rc.d scripts • Installed in the same way you would install httpd or any other application – Why recreate the wheel? Daemons seem to work ok for everything else. Unless you are *special*? Thursday, 8 November 12
  • 49. Located in different VCS roots • Each application is completely separate • Software developers see similarities and abstractions – And before you know it you have One Domain To Rule Them All • Domain Driven Design / Conways Law – Domains in different bounded contexts should be distinct – and its ok to have duplication – Use physical separation to enforce this • There will be common code, but it should be library and infrastructure code – Treat it as you would any other open source library – Stick it in a nexus repo somewhere and treat it as a binary dependency Thursday, 8 November 12
  • 50. Provisioned automatically • The way to manage the complexity of many small applications is declarative provisioning –UAT: • 2 * service A, Load Balanced, Auto-Scaled • 2 * service B, Load Balanced, Auto-Scaled • 1 * database cluster Thursday, 8 November 12
  • 51. Status aware and auto-scaling • What good is competing consumer if you only have one consumer? –We don’t want to wake Laura up at three in the morning any more to start a new process • Use watchdog processes to monitor in-app status pages –Each app exposes metrics about itself –In our case, queue-depth for example –This allows others services to auto-scale to meet throughput requirements Thursday, 8 November 12
  • 52. A single capability composed of many small applications and exposing a uniform interface of Atom Collections Thursday, 8 November 12
  • 53. How the capabilities form a product Thursday, 8 November 12
  • 54. They interact via the web’s uniform interface • HTTP – Don’t fight the battles already won – Use no-brainer force multipliers like reverse proxies • HATEOAS – Link relations drive state changes – Its an anti-corruption layer that allows the capability to evolve independently of its clients • Standard media types – Can be used by many different clients – You can monitor it using a feed reader if you want – and it makes your QA’s lives a *lot* easier Thursday, 8 November 12
  • 55. Capabilities poll each other for events, forming an eventually consistent system of systems atom+json / HTTP (AJOH) Monitoring Reporting Capability Capability (AJOH) (AJOH) atom+XML / HTTP User Fulfilment Capability Capability (AJOH) (AJOH) (AJOH) Inbound Batch Call Centre External Suppliers Thursday, 8 November 12
  • 56. Tip 6 Favour  service  choreography  over  orchestra>on Thursday, 8 November 12
  • 57. Each is decoupled from it’s clients. scalable, testable and deployable individually atom+json / HTTP (AJOH) Monitoring Reporting Capability Capability (AJOH) (AJOH) atom+XML / HTTP User Fulfilment Capability Capability (AJOH) (AJOH) (AJOH) Inbound Batch Call Centre External Suppliers Thursday, 8 November 12
  • 58. Tip 7 Use hypermedia controls to decouple services Thursday, 8 November 12
  • 59. Each developed by a separate team, using whatever tech they choose atom+json / HTTP (AJOH) Monitoring Reporting Capability Capability (AJOH) (AJOH) atom+XML / HTTP User Fulfilment Capability Capability (AJOH) (AJOH) (AJOH) Inbound Batch Call Centre External Suppliers Thursday, 8 November 12
  • 60. Our stack • Embedded Jetty (current project uses SimpleWeb) • PicoContainer for DI • Hibernate (but wrote our own SQL) • Abdera for Atom • Smoothie charts • Metrics @codahale • Graphite Thursday, 8 November 12
  • 61. Tip 8 Make it easy to do the right thing and hard to do the wrong thing use tooling and architectural tests to make complex tasks simple Thursday, 8 November 12
  • 62. Infrastructure automation stack • Fabric with boto • AWS, but deployable to anything with SSH • Maven (boo) • Git • Puppet for provisioning Thursday, 8 November 12
  • 64. this was hard to do well • We haven’t even talked about – Versioning – Integration – Testing – Deployment • Eventual Consistency can be tricky for people to get there head around • Developers like using enterprisy software – No one got fired for choosing an ESB – Convincing people to use the web is hard Thursday, 8 November 12
  • 66. The Unix Philosophy :s/pipes/hKp/   Lions commentary on Unix 2nd edition Thursday, 8 November 12
  • 67. Consistent and reinforcing practices Hexagonal Business capabilities composed of: Micro Services that you can Rewrite rather than maintain and which form A Distributed Bounded Context. Deployed as containerless OS services With standardised application protocols and message semantics Which are auto-scaling and designed for failure Thursday, 8 November 12
  • 68. Tip 9 Always have ten tips Thursday, 8 November 12
  • 69. Thanks! @boicy http://bovon.org jalewis@thoughtworks.com Thursday, 8 November 12