© 2016 Mesosphere, Inc. All Rights Reserved. 1
v0.1
MICROSERVICES
© 2016 Mesosphere, Inc. All Rights Reserved. 2
1. Overview
2. Design Principles
3. Deployment
4. 12 Factor App
5. Modular Containers
AGENDA
© 2016 Mesosphere, Inc. All Rights Reserved. 3
Microservices
OVERVIEW
© 2016 Mesosphere, Inc. All Rights Reserved.
noun | ˈmīkrō/ /ˈsərvəs/ :
an approach to application development in which a
large application is built as a suite of modular services.
Each module supports a specific business goal and
uses a simple, well-defined interface to communicate
with other modules.*
Microservices are designed to be flexible, resilient,
efficient, robust, and scalable.
*From whatis.com
OVERVIEW
© 2016 Mesosphere, Inc. All Rights Reserved.
OVERVIEW
Micro sized services
○ Efficiently scalable applications
○ Flexible applications
○ High performance
Application(s) powered by small services with
a single focus
Lightweight communication mechanism
Technology agnostic API
Independently changeable and deployable
Client
Service
Service
Service
UI
Service
© 2016 Mesosphere, Inc. All Rights Reserved.
MONOLITHIC
Challenges
○ No size restriction
○ Large codebase
○ Long development times
○ Inaccessible features
○ Highly coupled
○ Difficult to understand
Failure affects whole system
Changes may cause complete rebuild
Scaling requires duplication of entire system
Internal
Front
end
Accounts
Promotions
Orders
Payments
History
Data
Access
Databas
e
Service
Client
Account Orders
History
Codes
© 2016 Mesosphere, Inc. All Rights Reserved.
MICROSERVICES
Benefits
○ Shorter development times
○ Decoupled
○ Increased uptime
○ High scalable
○ Tested individually
○ Simpler to understand
Enables distributed teams
Right technology
Automated test tools
Promotions
Service
Orders
Service
Payments
Service
History
Service
API
Gateway
Client
Account Orders
History
Codes
Internal
Front
end
Accounts
Service
© 2016 Mesosphere, Inc. All Rights Reserved.
Functions & Logic
Microservices
(in containers)
Big Data + Analytics Engines
Streaming
Batch
Machine Learning
Analytics
Search
Time Series
SQL / NoSQL
Databases
THE MODERN ENTERPRISE APPLICATION
● Microservices
● Containers
● Stateful Big Data
● Open source
© 2016 Mesosphere, Inc. All Rights Reserved. 9
Microservices
DESIGN
PRINCIPLES
© 2016 Mesosphere, Inc. All Rights Reserved.
● High Cohesion: Single focus done well
● Autonomous: Independently changeable and deployable
● Business Domain Centric: Represents business function or domain
● Resilience: Embrace failure
● Observable: Centralized logging and monitoring
● Automation: Tools for testing and deployment
DESIGN PRINCIPLES
© 2016 Mesosphere, Inc. All Rights Reserved.
● High Cohesion
● Split service until it has a singular focus, only one reason to change
● Autonomous
● Loosely coupled, versioning strategy, ownership by team
● Business Domain Centric
● Identify business domains and subdivide into functions
● Resilience
● Design for failures, fail fast and recover fast
● Observable
● Tools for centralized monitoring and logging
● Automation
● Continuous Integration and continuous development tools
DESIGN PRINCIPLES
© 2016 Mesosphere, Inc. All Rights Reserved.
● Communication
● Synchronous or Asynchronous
● Hosting platform
● Cloud, on-prem, virtual machines, containers
● Service Discovery
● Monitoring and Logging Tools
● Performance
● Auto scaling, caching, load balancing
● Tools for centralized monitoring and logging
● Automation
● Continuous Integration and continuous development tools
DESIGN CONSIDERATIONS
© 2016 Mesosphere, Inc. All Rights Reserved. 13
Microservices
DEPLOYMENTS
© 2016 Mesosphere, Inc. All Rights Reserved.
● Brownfield
● Existing monolithic system
● Lacks microservices design principles
● Greenfield
● New project
● Evolving requirements
● First microservice
DEPLOYMENT TYPES
© 2016 Mesosphere, Inc. All Rights Reserved.
● Identify seams
● Separation that reflects domains
● Identify bounded contexts
● Seams are future microservice boundaries
● Modularize bounded contexts
● Move code incrementally
● Keep existing functionality intact
● Continuous unit testing and integration tests to validate
BROWNFIELD APPROACH
© 2016 Mesosphere, Inc. All Rights Reserved.
● Code organized into business domain or function
● Convert bounded contexts into microservices
● Start with the easiest one
● Maintain both versions for easy rollback
● Prioritize what to split by risk, technology, dependences
● Iterate incrementally
● Validate integration with monolithic
● Avoid shared databases, split using seams
● Consolidate reporting across microservices
BROWNFIELD MIGRATION
© 2016 Mesosphere, Inc. All Rights Reserved.
● Start with monolithic design
● High level picture
● Evolving seams
● Develop areas into modules
● Boundaries start to develop
● Refine and refactor design
● Eventually turn modules and shareable code libraries into services
● Review principles at each stage
● Map out target state and prioritize activities accordingly
GREENFIELD APPROACH
© 2016 Mesosphere, Inc. All Rights Reserved.
● Initially there will be:
● Longer development times
● Cost and training for tools and skills
● Addition testing
● Cost of improving infrastructure
● Cloud technologies
● Culture change
GREENFIELD CONSIDERATIONS
© 2016 Mesosphere, Inc. All Rights Reserved. 19
Microservices
12 FACTOR APP
© 2016 Mesosphere, Inc. All Rights Reserved.
Methodology for building software-as-a-service apps that:
● Use declarative formats for setup automation, to minimize time and cost
for new developers joining the project
● Have a clean contract with the underlying operating system, offering
maximum portability between execution environments
● Are suitable for deployment on modern cloud platforms, obviating the
need for servers and systems administration
● Minimize divergence between development and production, enabling
continuous deployment for maximum agility
● And can scale up without significant changes to tooling, architecture, or
development practices
From http://12factor.net/
12 FACTOR APP
© 2016 Mesosphere, Inc. All Rights Reserved.
I. Codebase
● One codebase tracked in revision control, many deploys
II. Dependencies
● Explicitly declare and isolate dependencies
III. Config
● Store config in the environment
IV. Backing Services
● Treat backing services as attached resources
From http://12factor.net/
12 FACTOR APP
© 2016 Mesosphere, Inc. All Rights Reserved.
V. Build, release, run
● Strictly separate build and run stages
VI. Processes
● Execute the app as one or more stateless processes
VII. Port binding
● Export services via port binding
VIII. Concurrency
● Scale out via the process model
From http://12factor.net/
12 FACTOR APP
© 2016 Mesosphere, Inc. All Rights Reserved.
IX. Disposability
● Maximize robustness with fast startup and graceful shutdown
X. Dev/prod parity
● Keep development, staging, and production as similar as possible
XI. Logs
● Treat logs as event streams (log to stdout & stderr)
XII. Admin processes
● Run admin/management tasks as one-off processes
From http://12factor.net/
12 FACTOR APP
© 2016 Mesosphere, Inc. All Rights Reserved. 24
Microservices
MODULAR
CONTAINERS
© 2016 Mesosphere, Inc. All Rights Reserved.
● Proper Linux process
● React to signals, return proper exit codes, use standard streams
● Explicit interfaces
● Make dependencies explicit (CLI args, env vars, labels)
● Disposable
● Keep ephemeral state, robust against failure, minimal setup
● Immutable
● Changes to container should be made by rebuilding
● Self-contained
● Zero-config deploy, add dependencies at build time, dynamic configs
MODULAR CONTAINER
© 2016 Mesosphere, Inc. All Rights Reserved.
SUMMARY
In this module we looked at microservices
- Monolithic applications to microservices
- Design principles
- Deployment considerations
- 12 factor app methodology
- Building modular containers
A09 - Microservices.pptx

A09 - Microservices.pptx

  • 1.
    © 2016 Mesosphere,Inc. All Rights Reserved. 1 v0.1 MICROSERVICES
  • 2.
    © 2016 Mesosphere,Inc. All Rights Reserved. 2 1. Overview 2. Design Principles 3. Deployment 4. 12 Factor App 5. Modular Containers AGENDA
  • 3.
    © 2016 Mesosphere,Inc. All Rights Reserved. 3 Microservices OVERVIEW
  • 4.
    © 2016 Mesosphere,Inc. All Rights Reserved. noun | ˈmīkrō/ /ˈsərvəs/ : an approach to application development in which a large application is built as a suite of modular services. Each module supports a specific business goal and uses a simple, well-defined interface to communicate with other modules.* Microservices are designed to be flexible, resilient, efficient, robust, and scalable. *From whatis.com OVERVIEW
  • 5.
    © 2016 Mesosphere,Inc. All Rights Reserved. OVERVIEW Micro sized services ○ Efficiently scalable applications ○ Flexible applications ○ High performance Application(s) powered by small services with a single focus Lightweight communication mechanism Technology agnostic API Independently changeable and deployable Client Service Service Service UI Service
  • 6.
    © 2016 Mesosphere,Inc. All Rights Reserved. MONOLITHIC Challenges ○ No size restriction ○ Large codebase ○ Long development times ○ Inaccessible features ○ Highly coupled ○ Difficult to understand Failure affects whole system Changes may cause complete rebuild Scaling requires duplication of entire system Internal Front end Accounts Promotions Orders Payments History Data Access Databas e Service Client Account Orders History Codes
  • 7.
    © 2016 Mesosphere,Inc. All Rights Reserved. MICROSERVICES Benefits ○ Shorter development times ○ Decoupled ○ Increased uptime ○ High scalable ○ Tested individually ○ Simpler to understand Enables distributed teams Right technology Automated test tools Promotions Service Orders Service Payments Service History Service API Gateway Client Account Orders History Codes Internal Front end Accounts Service
  • 8.
    © 2016 Mesosphere,Inc. All Rights Reserved. Functions & Logic Microservices (in containers) Big Data + Analytics Engines Streaming Batch Machine Learning Analytics Search Time Series SQL / NoSQL Databases THE MODERN ENTERPRISE APPLICATION ● Microservices ● Containers ● Stateful Big Data ● Open source
  • 9.
    © 2016 Mesosphere,Inc. All Rights Reserved. 9 Microservices DESIGN PRINCIPLES
  • 10.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● High Cohesion: Single focus done well ● Autonomous: Independently changeable and deployable ● Business Domain Centric: Represents business function or domain ● Resilience: Embrace failure ● Observable: Centralized logging and monitoring ● Automation: Tools for testing and deployment DESIGN PRINCIPLES
  • 11.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● High Cohesion ● Split service until it has a singular focus, only one reason to change ● Autonomous ● Loosely coupled, versioning strategy, ownership by team ● Business Domain Centric ● Identify business domains and subdivide into functions ● Resilience ● Design for failures, fail fast and recover fast ● Observable ● Tools for centralized monitoring and logging ● Automation ● Continuous Integration and continuous development tools DESIGN PRINCIPLES
  • 12.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● Communication ● Synchronous or Asynchronous ● Hosting platform ● Cloud, on-prem, virtual machines, containers ● Service Discovery ● Monitoring and Logging Tools ● Performance ● Auto scaling, caching, load balancing ● Tools for centralized monitoring and logging ● Automation ● Continuous Integration and continuous development tools DESIGN CONSIDERATIONS
  • 13.
    © 2016 Mesosphere,Inc. All Rights Reserved. 13 Microservices DEPLOYMENTS
  • 14.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● Brownfield ● Existing monolithic system ● Lacks microservices design principles ● Greenfield ● New project ● Evolving requirements ● First microservice DEPLOYMENT TYPES
  • 15.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● Identify seams ● Separation that reflects domains ● Identify bounded contexts ● Seams are future microservice boundaries ● Modularize bounded contexts ● Move code incrementally ● Keep existing functionality intact ● Continuous unit testing and integration tests to validate BROWNFIELD APPROACH
  • 16.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● Code organized into business domain or function ● Convert bounded contexts into microservices ● Start with the easiest one ● Maintain both versions for easy rollback ● Prioritize what to split by risk, technology, dependences ● Iterate incrementally ● Validate integration with monolithic ● Avoid shared databases, split using seams ● Consolidate reporting across microservices BROWNFIELD MIGRATION
  • 17.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● Start with monolithic design ● High level picture ● Evolving seams ● Develop areas into modules ● Boundaries start to develop ● Refine and refactor design ● Eventually turn modules and shareable code libraries into services ● Review principles at each stage ● Map out target state and prioritize activities accordingly GREENFIELD APPROACH
  • 18.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● Initially there will be: ● Longer development times ● Cost and training for tools and skills ● Addition testing ● Cost of improving infrastructure ● Cloud technologies ● Culture change GREENFIELD CONSIDERATIONS
  • 19.
    © 2016 Mesosphere,Inc. All Rights Reserved. 19 Microservices 12 FACTOR APP
  • 20.
    © 2016 Mesosphere,Inc. All Rights Reserved. Methodology for building software-as-a-service apps that: ● Use declarative formats for setup automation, to minimize time and cost for new developers joining the project ● Have a clean contract with the underlying operating system, offering maximum portability between execution environments ● Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration ● Minimize divergence between development and production, enabling continuous deployment for maximum agility ● And can scale up without significant changes to tooling, architecture, or development practices From http://12factor.net/ 12 FACTOR APP
  • 21.
    © 2016 Mesosphere,Inc. All Rights Reserved. I. Codebase ● One codebase tracked in revision control, many deploys II. Dependencies ● Explicitly declare and isolate dependencies III. Config ● Store config in the environment IV. Backing Services ● Treat backing services as attached resources From http://12factor.net/ 12 FACTOR APP
  • 22.
    © 2016 Mesosphere,Inc. All Rights Reserved. V. Build, release, run ● Strictly separate build and run stages VI. Processes ● Execute the app as one or more stateless processes VII. Port binding ● Export services via port binding VIII. Concurrency ● Scale out via the process model From http://12factor.net/ 12 FACTOR APP
  • 23.
    © 2016 Mesosphere,Inc. All Rights Reserved. IX. Disposability ● Maximize robustness with fast startup and graceful shutdown X. Dev/prod parity ● Keep development, staging, and production as similar as possible XI. Logs ● Treat logs as event streams (log to stdout & stderr) XII. Admin processes ● Run admin/management tasks as one-off processes From http://12factor.net/ 12 FACTOR APP
  • 24.
    © 2016 Mesosphere,Inc. All Rights Reserved. 24 Microservices MODULAR CONTAINERS
  • 25.
    © 2016 Mesosphere,Inc. All Rights Reserved. ● Proper Linux process ● React to signals, return proper exit codes, use standard streams ● Explicit interfaces ● Make dependencies explicit (CLI args, env vars, labels) ● Disposable ● Keep ephemeral state, robust against failure, minimal setup ● Immutable ● Changes to container should be made by rebuilding ● Self-contained ● Zero-config deploy, add dependencies at build time, dynamic configs MODULAR CONTAINER
  • 26.
    © 2016 Mesosphere,Inc. All Rights Reserved. SUMMARY In this module we looked at microservices - Monolithic applications to microservices - Design principles - Deployment considerations - 12 factor app methodology - Building modular containers