Microservices Design

Introduction:

  1. All services are configured programmatically by an API.
  2. Events are the driving force (event-driven, pub/sub model, trigger/action)
  3. Documentation is a first-class citizen.
  4. Live and die with 12-factor
  5. Services should have a single purpose (do one thing and do it well), be loosely coupled (know little about each other), and have high cohesion (encapsulates all related functionality and data together).

Major Parts:

  1. Application
  2. Pipelines
  3. Platform

microservices-overview

Application

Contains live services.

Major Parts:

  1. APIs
  2. Storage
  3. Docs

APIs

  1. Powered by web frameworks (Java/Spring Boot, Python/Flask, Node/Express etc.)
  2. Languages and frameworks don’t matter as much as solid API contracts.
  3. Single Responsibility.
  4. 12 Factor
  5. Immutability has to be considered.
  6. Documentation is key - Swagger / OpenAPI spec.
  7. Handle auth. Manage API Gateway.

Storage

Tools:

  1. Databases (MongoDB, Postgres, Redis)
  2. Task Queues
  3. Message Brokers (RabbitMQ, Kafka)

Issues:

  1. Storage is a hard problem.
  2. Containers are ephemeral, data is not.
  3. Do you have a database per service or a shared database?
  4. Disaster recovery? Testing?

Platform

Major Parts:

  1. Software defined networks
  2. Service discovery
  3. Health checks (side cars approach)
  4. Logging
  5. Monitoring
  6. Load balancing
  7. Path-based routing
  8. Circuit breaking

Tools

  1. Kubernetes
  2. Docker Swarm
  3. Mesos
  4. Nomad
  5. Fully-managed: EKS, GKE, ECS
  6. Ubuntus MAAS (metal as a service)
  7. OpenStack

Pipelines

Continuos Integration

Triggers:

  1. Commit to source repo, build and test project. (automation)

Tools

  1. Github, GitLab, Git
  2. Jenkins, Travis, Circle
  3. AWS, GCP, Azure
  4. Docker Repos
  5. Linters, static code analysis

Continuous Delivery

Triggers:

  1. On successful build, deploy

Tools

  1. Shell scripts
  2. Fabric (shell scripts on steroids)
  3. Terraform templates
  4. AWS (CodeDeploy, CodePipeline, CloudFormation), GCP, Azure
  5. Concourse
  6. Spinnaker
  7. Old Tools (Ansible, Chef, Puppet)

microservices-overview-ci-cd