DevOps Foundations Microservices
GitbookCourses2021-02-22
๐ก DevOps Foundations: Microservices
๐ช 1. Microservices In Production
-
Decoupling
multiple tech stacks
- services are deployed and scaled independently
- implementation and changes are isolated
- Increased cohesion (ๅ่): different boundaries
-
Increased development velocity (้ๅบฆ) and diversity (ๅคๅ ๅ)
- smaller services, smaller teams
- Multiple tech stacks
- Increased operational complexity
- Distributed systems
- Eventual consistency
๐ The 3 common characteristic of well-defined microservices
- Domain-Driven Design
- Loose Coupling, High Cohesion (ๆพ่ฆๅ๏ผ้ซๅ ่ๅ)
- Continuous Delivery
๐ช 2. Service Readiness
๐ Standardization
- exemplars ่ไพ
- Service Templates: Dropwizard, Governator, Cookiecutter
๐ Unit and integration testing
- Gateway Integration Tests
- Persistence Integration Tests
- Component: In-Process, Out-of-Process Component Tests
๐ End-to-end and contract testing
๐ Contract test
Contract-driven contracts define the expectations of a consumer on a service.
๐ Performance testing: sinon
๐ Continuous integration: git commit
๐ Continuous delivery: Travis CI, Jenkens
In order for continous delivery to be archieved, a build pipeline must create an artifact from source control
๐ Platform-specific and OS artifacts
-
What is the recommended approach for structuring code in a microservices architecture?
Have 1 repository, 1 build pipeline, and 1 artifact per microservice.
- In a microservices architecture, system as a whole should be the focus of performance testing.
๐ Virtual machine and container artifacts: Docker
๐ Versioning: semantic version(^~): major.minor.patch
๐ Basic service discovery
- service registy + basic discovery
-
service discovery with DNS
example of domain-based environments (service_name-environment-organization):
research-performance.bestitconsulting.com
๐ Dynamic service registries
-
2
Discovery
Patterns:Client-side
discovery, e.g: Netflix Open-Source ToolsEureka
- service registryRibbon
- client-side load balancerServer-side
discovery- Console and Nginx
- Kubernetes
-
2
Registration
Patterns:Self-registration
: heatbeat requestThird-party
registration
๐ Documentation
- JIRA, sprint story
- Swagger UI: yaml, json, no disquz comments
- gitbook, markdown
๐ Ownership and Conwayโs law
๐ช 3. Service Resilience, Reliability, and Scalability
๐ Architectural safety measures
๐ Integration methodologies (ๆนๆณ่ฎบ)
- shared Database
- Synchronous communicatiton
- Asynchronous communicatiton
-
Orchestration vs. Choreography ็ผๆไธ็ผ่
- A service collaboration pattern that relies on a
central
brain to guide and drive business processes - describes a system where each part is told what its job is and lets the part itself work out the details.
- A service collaboration pattern that relies on a
๐ Synchronous integration technologies
- RPC
- REST: Resources, HATEOAS
GraphQL
: API standard that combines RPC with the REST concept of resources in order to make API interactions more efficient
๐ Asynchronous integration technologies
- Emit events
- Message Broker: Smart endpoints, dumb pipes
๐ Logging
(A) Log Aggregation Tools: (่ๅ)
-
ELK Stack: Elasticsearch, Logstash, and Kibana, Beats.
โELKโ is the acronym for three open source projects:
Elasticsearch
,Logstash
, andKibana
.Elasticsearch
is a search and analytics engine.Logstash
is a serverโside data processing pipeline that ingests data from multiple sources simultaneously, transforms it, and then sends it to a โstashโ likeElasticsearch
.Kibana
lets users visualize data with charts and graphs in Elasticsearch.The
Elastic Stack
is the next evolution of the ELK Stack. - Grafana
(B) Standarize log format
(C) Correlation ID (็ธๅ ณๆง)
A global unique identifier generated and propagated across service calls for a request.
(D) Distributed Tracing Tools
- Zipkin
- Jaeger
๐ Monitoring
(A) Dashboard: metrics
(B) Synthetic (ๅๆ็) Monitoring
(C) Metrics Aggregation Tools: Grafana, Graphite, Prometheus
๐ Alerting
- On-Call Rotation
๐ Incidents (ไบไปถ)
- Assessment
- Coordination
- Mitigation ๅ่ฝป
- Resolution
- Follow-Up
๐ Services-level Objectives (SLOs) and error budgets
- SLI: initial indicator.
- A specified target level expressing the desired reliability of a service
- ๆๅก็บงๅซ็ฎๆ ๆฏๆๆๅกๆไพ่ ๅๅฎขๆทไฝๅบ็ๆๅไฟ่ญ็้ๅๆๆจใไพๅฆ่ปไปถๆไพๅๅๅฎขๆถไฟ่ญไธๅนด็ๆ้ๅ งๆ 99.95%็ๆ้ๆ็จ็จๅบไธๆๅบ็พๆ ้๏ผๆๆฏไธๅๆไปฅๅ ง 75๏ผ ็ๆฅๆ็ๅผๅซไธญๅฟๆฑๅฉ็ต่ฏๅฐๅจไธๅ้ๅ ๅพๅฐ็ญๅคใ้ๅฐฑๆฏไธ็จฎๅ ธๅ็ๆๅก็บงๅซ็ฎๆ ่ชชๆใ
-
SLOs help determine what engineering work to prioritize:
- Availability
- Latency
- Throughtput
- Correctness
๐ Capacity planing ๅฎน้
- The process to determine the hardware needs of a service.
- Aualitative, Quantitative Growth Scale
- Utilize Autoscaling
๐ช 4. Microservices by Example
๐ Overview of KinetEco case study
๐ Greenfield services
- created a service template
- used existing CI infrastructure
- created a shared library for CI/CD functionality and shared base images
- Kubernetes
๐ Splitting the monolith
- seams: ๆฅ็ผ
๐ User-facing authentication and aurthorization
๐ Service-to-service authentication antipatterns
- Authentication and Authorization ่ฎค่ฏไธๆๆ
- Network-based Protection
- Basic Authentication

๐ Service-to-service authentication
- Single Sign-On
- Client Certificates
- HMAC HTTP Request
- API Keys
๐ Challenges adopting microservices
- API Versioning
- Kubernetes
- Reporting