Microservice Architecture

, Yoshinori Oe, Container

What is Microservice Architecture

Compared with Monolith Architecture

Monolith Organization

microservice conways-law

Microservice Organization

microservice prefer functional staff

(Source : Martin Fowler)

Monolith Development Flow

monolith development

Microservice Development Flow

microservice development

Characteristics

  • Loose Coupling, High Cohesion, Componentization of BusinesLogic, Design of fault occurrence assumption, Design based on updateing frequently
  • Need to divide each team per domain (each services as max 8 members)
  • One team take responsibility for all phases as Requirements Definition, Design, Implementation, Test, and Operation
  • Team members need to have more wider fields knowledges

Understanding Microservice at an organization

microservice principle(Source : Building Microservices)

  • Microservice (Small autonomous services)
    • Modeled around business concepts
    • Culture of automation
    • Hide internal implementation details
    • Decentralize all the things
    • Deploy independently
    • Isolate failure
    • Highly obsevable

One sample case of requirement technical consideration

  • Collaboration method : Choreography or Orchestration
  • Communication method : REST API and asyncronous processing via messaging que or pub/sub btw services
  • UI : API Synthesis
  • Recovery method : Circuit Braker
  • Security : Use SAML/OpenID Connect API key
  • Test : consumer-driven contract (CDC) Blue-Green Deployment, Canary Deployment
  • Scaling : on CAP Theorem (consistency, availability, and partition tolerance) -> pick AP system with “eventually consistent”
  • Monitoring : logging, metrics, monitoring whole system, distributed tracing

Advantages / Purpose to use Microservice Architecture

microservice advantage(Source : Building Microservices)

  • Strategic goals
    • Enable scalable business
    • Support entry into new markets
    • Support innovation in existing markets
  • Architectural principles
    • Reduce inertia
    • Eliminate accidental complexity
    • Consistent interfaces and data flows
    • (No silver bullets)
  • Design and Delivery practices
    • Standard REST/HTTP
    • Encapsulate legacy
    • Eliminate integration databases
    • Consolidate and cleanse data
    • Published integration model
    • Small independent services
    • Continuous deployment
    • Minimal customization of COTS/SAAS

Use Cases

  • Amazon
  • Netfllix
  • Twitter
  • Cookpad
  • Fast Retailing

Disadvantages / Difficulity to use Microservice Architecture

  • Difficult to decide where to put the component boundaries
  • Difficult to migrate of code beyond service boundaries
  • Not easy to interface change
  • Need to keep backward compatibility
    • API versioning, extended rules (like example.com/v1/api)
  • Test becomes complicated
  • Higher skill is required
  • Initially should not start with Microservices architecture
    • Monolithic first, then migrate to Microservice
  • Infrastructure costs increase basically
  • Becomes more complicated than monolithic service
  • Difficult to guarantee data consistency
  • More difficult to investigate the cause of the bug

How to migrate from Monolith to Microservice effectively

microservice integration(Source : Building Microservices)

microservice productivity(Source : Martin Fowler)

Points to keep in mind

  • Migrate a service little by little (Do not migrate as Big Bang)
  • 1st step is “Divide Databases”
  • 2nd step is “Divide Services”
  • For stable productivity, it’s good time to migrate from Monolith to Microservice¬†after the service becomes more complex