Microservices
Microservices Design
Introduction:
- All services are configured programmatically by an API.
- Events are the driving force (event-driven, pub/sub model, trigger/action)
- Documentation is a first-class citizen.
- Live and die with 12-factor
- 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:
- Application
- Pipelines
- Platform
Application
Contains live services.
Major Parts:
- APIs
- Storage
- Docs
APIs
- Powered by web frameworks (Java/Spring Boot, Python/Flask, Node/Express etc.)
- Languages and frameworks don’t matter as much as solid API contracts.
- Single Responsibility.
- 12 Factor
- Immutability has to be considered.
- Documentation is key - Swagger / OpenAPI spec.
- Handle auth. Manage API Gateway.
Storage
Tools:
- Databases (MongoDB, Postgres, Redis)
- Task Queues
- Message Brokers (RabbitMQ, Kafka)
Issues:
- Storage is a hard problem.
- Containers are ephemeral, data is not.
- Do you have a database per service or a shared database?
- Disaster recovery? Testing?
Platform
Major Parts:
- Software defined networks
- Service discovery
- Health checks (side cars approach)
- Logging
- Monitoring
- Load balancing
- Path-based routing
- Circuit breaking
Tools
- Kubernetes
- Docker Swarm
- Mesos
- Nomad
- Fully-managed: EKS, GKE, ECS
- Ubuntus MAAS (metal as a service)
- OpenStack
Pipelines
Continuos Integration
Triggers:
- Commit to source repo, build and test project. (automation)
Tools
- Github, GitLab, Git
- Jenkins, Travis, Circle
- AWS, GCP, Azure
- Docker Repos
- Linters, static code analysis
Continuous Delivery
Triggers:
- On successful build, deploy
Tools
- Shell scripts
- Fabric (shell scripts on steroids)
- Terraform templates
- AWS (CodeDeploy, CodePipeline, CloudFormation), GCP, Azure
- Concourse
- Spinnaker
- Old Tools (Ansible, Chef, Puppet)