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 Tools
    • Eureka - service registry
    • Ribbon - client-side load balancer
    • Server-side discovery
    • Console and Nginx
    • Kubernetes
  • 2 Registration Patterns:

    • Self-registration: heatbeat request
    • Third-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.

๐Ÿ“‘ 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, and Kibana. 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โ€ like Elasticsearch. 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
devops ms 1

๐Ÿ“‘ Service-to-service authentication

  • Single Sign-On
  • Client Certificates
  • HMAC HTTP Request
  • API Keys

๐Ÿ“‘ Challenges adopting microservices

  • API Versioning
  • Kubernetes
  • Reporting