Kiến trúc Microservices – Từ cơ bản đến nâng cao

I. Giới thiệu khóa học:

Khóa học "Kiến trúc Microservices – Từ cơ bản đến nâng cao" được thiết kế theo hướng chuyên sâu, cung cấp cho học viên nền tảng kiến thức vững chắc và toàn diện về kiến trúc Microservices – một trong những mô hình kiến trúc phần mềm phổ biến nhất hiện nay trong xây dựng hệ thống phân tán, khả năng mở rộng cao và dễ bảo trì.

Khóa học đi từ những khái niệm nền tảng (Monolith vs Microservices, nguyên lý thiết kế, API Gateway, Service Discovery) đến các chủ đề nâng cao (Event-Driven Architecture, Saga Pattern, CQRS, Container Orchestration, Observability, Security).
Ngày 1 & 2 và buổi sáng ngày 3 tập trung hoàn toàn vào lý thuyết chuyên sâu, phân tích case study và thảo luận. Buổi chiều ngày 3 và ngày 4 dành cho thực hành tổng hợp (Hands-on Workshop) và Q&A, giúp học viên áp dụng toàn bộ kiến thức đã học vào một dự án thực tế.

II. Thời lượng: 32 giờ (4 ngày)
III. Hình thức đào tạo:

Đào tạo trực tiếp tại lớp học, đào tạo online tương tác với giảng viên, đào tạo kết hợp online và trực tiếp tại lớp học, đào tạo tại văn phòng khách hàng theo yêu cầu

IV. Mục tiêu khóa học:
  • Kiến thức nền tảng: Hiểu rõ bản chất, lịch sử phát triển, nguyên lý thiết kế và các pattern cốt lõi của kiến trúc Microservices.
  • Kiến trúc & Thiết kế: Có khả năng phân tích, thiết kế và phân chia một hệ thống Monolith thành các Microservices độc lập theo đúng chuẩn.
  • Giao tiếp giữa Services: Nắm vững các cơ chế giao tiếp: REST API, gRPC, Message Queue (Kafka/RabbitMQ), Event Bus, và biết khi nào dùng cơ chế nào.
  • Quản lý dữ liệu: Hiểu sâu về quản lý dữ liệu phân tán: Database per Service, Saga Pattern (Choreography & Orchestration), CQRS, Event Sourcing.
  • Triển khai & Vận hành: Hiểu cách triển khai Microservices trên Docker, Kubernetes, CI/CD pipeline, và chiến lược deployment (Blue-Green, Canary).
  • Observability: Hiểu ba trụ cột Observability: Logging (ELK), Monitoring (Prometheus/Grafana), Tracing (Jaeger/OpenTelemetry).
  • Bảo mật: Hiểu các cơ chế bảo mật: OAuth2, JWT, API Gateway auth, mTLS, Zero Trust Architecture, Secrets Management.
  • Tối ưu & Resilience: Hiểu các pattern tối ưu: Caching (Redis), Rate Limiting, Circuit Breaker, Retry, Bulkhead, Load Balancing.
V. Đối tượng tham gia

Khóa học này được thiết kế phù hợp cho:

  • Software Developers / Software Engineers (Java, .NET, Python, Node.js, Go).
  • Backend Developers muốn chuyển đổi từ Monolith sang Microservices.
  • DevOps Engineers / Platform Engineers / Site Reliability Engineers (SRE).
  • Solution Architects / Technical Architects / System Architects.
  • Tech Leads / Engineering Managers.
  • Sinh viên CNTT năm cuối hoặc mới ra trường có kiến thức lập trình nền tảng.
  • Bất kỳ ai quan tâm đến kiến trúc hệ thống phân tán và Cloud-Native Development.
VI. Điều kiện tiên quyết:
  • Kinh nghiệm lập trình: Ít nhất 1-2 năm kinh nghiệm lập trình với bất kỳ ngôn ngữ: Java, Python, Node.js, Go, C#, v.v.
  • Kiến thức Web: Hiểu biết cơ bản về HTTP/HTTPS, RESTful API, JSON, Web protocols.
  • Cơ sở dữ liệu: Quen thuộc với SQL (PostgreSQL/MySQL) và khái niệm cơ bản về NoSQL (MongoDB/Redis).
  • Linux & CLI: Biết sử dụng command line Linux cơ bản (cd, ls, grep, chmod, ssh, curl).
  • Version Control: Sử dụng được Git (clone, commit, push, pull, branch, merge).
  • Docker cơ bản: Ưu tiên: Đã từng sử dụng Docker – nếu chưa sẽ có phần ôn tập nhanh trong buổi thực hành.
VII. Công cụ và công nghệ được giới thiệu
  • Ngôn ngữ lập trình: Java (Spring Boot) / Node.js / Python / Go. Mục đích: Xây dựng microservices.
  • Containerization: Docker, Docker Compose. Mục đích: Đóng gói và chạy multi-container.
  • Orchestration: Kubernetes (Minikube/Kind), Helm. Mục đích: Triển khai & quản lý containers ở scale.
  • API & Communication: REST, gRPC, GraphQL, Protocol Buffers. Mục đích: Giao tiếp giữa các services.
  • Message Queue: Apache Kafka, RabbitMQ. Mục đích: Asynchronous messaging & event streaming.
  • Database: PostgreSQL, MongoDB, Redis. Mục đích: SQL, NoSQL, Caching.
  • API Gateway: Kong, NGINX, Express Gateway. Mục đích: Routing, rate limiting, auth.
  • Monitoring: Prometheus, Grafana. Mục đích: Metrics collection & visualization.
  • Logging: ELK Stack (Elasticsearch, Logstash, Kibana). Mục đích: Centralized logging & search.
  • Tracing: Jaeger, Zipkin, OpenTelemetry. Mục đích: Distributed tracing.
  • CI/CD: GitHub Actions, GitLab CI, ArgoCD. Mục đích: Tự động hóa build, test, deploy.
  • Security: OAuth2, JWT, HashiCorp Vault, mTLS. Mục đích: Authentication, authorization, secrets.
  • Testing: Postman, JMeter, Chaos Monkey, Pact. Mục đích: API testing, load testing, chaos.
  • Resilience: Resilience4j, Polly. Mục đích: Circuit Breaker, Retry, Bulkhead.
VIII. Nội dung khóa học:

PHẦN 1: NỀN TẢNG MICROSERVICES – KHÁI NIỆM & THIẾT KẾ
(LÝ THUYẾT)

Mục tiêu: Hiểu rõ bản chất Microservices, nguyên lý thiết kế, giao tiếp giữa services, container hóa.

1. Ôn tập & Giới thiệu tổng quan

  • Ôn tập nhanh kiến thức nền: HTTP/HTTPS, REST API, JSON, Status Codes.
  • Distributed Systems basics: CAP Theorem, eventual consistency, network partitions.
  • Giới thiệu khóa học: nội dung, lộ trình, tài liệu tham khảo.
  • Tổng quan bức tranh toàn cảnh: hệ sinh thái Microservices.

2. Từ Monolith đến Microservices

  • Kiến trúc Monolith: ưu điểm, nhược điểm, khi nào phù hợp.
  • Lịch sử phát triển: Monolith → SOA → Microservices.
  • SOA vs Microservices: điểm giống và khác biệt cốt lõi.
  • Microservices: định nghĩa, 7 đặc điểm cốt lõi (Single Responsibility, Autonomous, Isolated, Decentralized Governance, Independently Deployable, Evolutionary Design, Organized around Business).
  • Khi nào NÊN và KHÔNG NÊN dùng Microservices.
  • Case study phân tích: Amazon, Netflix, Uber – hành trình chuyển đổi.

3. Nguyên lý thiết kế & Domain-Driven Design

  • 12-Factor App methodology: phân tích từng factor và ứng dụng.
  • Domain-Driven Design (DDD):
    • Bounded Context, Ubiquitous Language, Context Mapping.
    • Entities, Value Objects, Aggregates, Domain Events.
  • Cách xác định Service Boundaries: phân chia theo business capability.
  • Phân tích case study: Hệ thống E-commerce – xác định các services.
    • User Service, Product Catalog, Order, Payment, Inventory, Notification.
  • Thảo luận nhóm: Phân chia hệ thống Banking thành Microservices

4. API Gateway & Service Communication

  • API Gateway: vai trò, routing, load balancing, rate limiting.
  • So sánh các API Gateway: Kong, NGINX, AWS API Gateway, Express Gateway.
  • Service-to-service Communication:
    • Synchronous: REST, gRPC, GraphQL – khi nào dùng gì?
    • Asynchronous: Message Queue, Event Bus.
  • RESTful API best practices:
    • Versioning strategies, pagination, HATEOAS.
    • Error handling, Idempotency, Rate Limiting.
  • gRPC & Protocol Buffers: khái niệm, so sánh với REST.
  • Phân tích trade-offs: Latency vs Reliability vs Complexity.

5. Service Discovery & Configuration Management

  • Service Discovery:
    • Client-side discovery (Netflix Ribbon, gRPC client-side LB).
    • Server-side discovery (Kubernetes Services, AWS ALB).
  • Service Registry: Consul, Eureka, etcd, ZooKeeper.
  • Health Checking: Liveness vs Readiness probes.
  • Externalized Configuration:
    • Centralized config management: Spring Cloud Config, Consul KV.
    • Environment variables, ConfigMaps, Secrets.
    • Dynamic configuration reload, Feature Flags.

6. Container hóa với Docker – Kiến thức nền tảng

  • Tại sao cần Container hóa trong Microservices?
  • Docker fundamentals:
    • Image, Container, Volume, Network (bridge, host, overlay).
    • Dockerfile: best practices, multi-stage build, layer caching.
    • Docker Compose: orchestrating multi-container.
  • Container Registry: Docker Hub, AWS ECR, GCR, Harbor.
  • So sánh: VM vs Container vs Serverless.
  • Container Security: image scanning, least privilege, secrets.
  • Demo: Quá trình build → ship → run container.

PHẦN 2: XÂY DỰNG MICROSERVICES & QUẢN LÝ DỮ LIỆU PHÂN TÁN
(LÝ THUYẾT)

Mục tiêu: Hiểu sâu về xây dựng services, giao tiếp async, quản lý dữ liệu phân tán, resilience patterns.

1. Xây dựng Microservice – Architecture & Best Practices

  • Microservice internal architecture:
    • Layered Architecture, Hexagonal Architecture (Ports & Adapters).
    • Project structure conventions & best practices.
  • Design patterns: Repository, Dependency Injection, CQRS basics.
  • Error handling & validation patterns.
  • Logging standards: structured logging, correlation IDs
  • API Contract-first design: OpenAPI/Swagger specification.
  • Phân tích: Spring Boot / Node.js / Go microservice template.

2. Asynchronous Communication & Message Queues

  • Tại sao cần Asynchronous Communication?
  • Message Queue vs Event Streaming: điểm khác biệt cốt lõi.
  • Apache Kafka fundamentals:
    • Architecture: Brokers, Topics, Partitions, Replication.
    • Producer, Consumer, Consumer Groups.
    • Delivery guarantees: At most once, At least once, Exactly once.
    • Kafka Streams & KTable cơ bản.
  • RabbitMQ: Exchanges, Queues, Routing patterns.
  • Publish-Subscribe vs Point-to-Point patterns.
  • So sánh: Kafka vs RabbitMQ vs AWS SQS/SNS vs Azure Service Bus.
  • Message ordering, idempotency, dead-letter queues.

3. Event-Driven Architecture

  • Event-Driven Architecture (EDA): khái niệm, lợi ích, challenges.
  • Event Sourcing pattern:
    • State as sequence of events, event store, snapshots.
    • Ưu/nhược điểm, khi nào nên dùng.
  • Integration Events vs Domain Events.
  • Event Schema evolution & versioning.
  • Outbox Pattern: giải pháp reliable event publishing.
  • Phân tích flow: Order Created → Inventory Reserved → Payment Processed.
  • Thảo luận: E-commerce event storming exercise.

4. Data Patterns trong Microservices

  • Database per Service pattern: nguyên lý, trade-offs.
  • Shared Database anti-pattern: khi nào chấp nhận được?
  • Saga Pattern:
    • Choreography: event-based coordination, ưu/nhược điểm.
    • Orchestration: centralized controller (Camunda, Temporal).
    • Compensating transactions & failure handling.
  • CQRS (Command Query Responsibility Segregation):
    • Tách read model và write model.
    • Eventual consistency implications.
  • Phân tích Saga flow: Order → Payment → Shipping (compensation).
  • Distributed transactions: tại sao Two-Phase Commit không phù hợp.

5. Caching & API Optimization

  • Distributed Caching strategies:
    • Cache-Aside (Lazy Loading), Write-Through, Write-Behind, Refresh-Ahead.
  • Redis: Data structures, Pub/Sub, Streams, Clustering.
  • API Response Caching: ETags, Last-Modified, Cache-Control headers.
  • CDN & Edge caching cho Microservices.
  • Rate Limiting & Throttling:
    • Token Bucket, Leaky Bucket, Sliding Window algorithms
    • API Gateway rate limiting vs Service-level rate limiting
  • Data compression & serialization optimization (Protobuf vs JSON).
  • Connection pooling & keep-alive strategies.

6. Resilience & Reliability Patterns

  • Circuit Breaker Pattern (Resilience4j / Polly):
    • Closed → Open → Half-Open states.
    • Configuration: failure threshold, timeout, reset window.
  • Retry Pattern: exponential backoff, jitter, max retries.
  • Fallback Pattern: graceful degradation strategies.
  • Timeout Pattern: connection timeout vs read timeout.
  • Bulkhead Isolation: thread pool isolation, semaphore isolation.
  • Health Check endpoints: Liveness, Readiness, Startup probes.
  • Load Balancing: algorithms (Round Robin, Weighted, Least Connections).
  • Chaos Engineering principles: giải thích, công cụ (Chaos Monkey, Litmus).
  • Tổng hợp: Resilience Matrix – áp dụng patterns nào cho tình huống nào.

PHẦN 3: TRIỂN KHAI, VẬN HÀNH (LÝ THUYẾT) + THỰC HÀNH & Q&A

Mục tiêu: Triển khai K8s, Observability, Security. Hands-on Workshop tổng hợp + Q&A

1. Container Orchestration với Kubernetes

  • Tại sao cần Orchestrator khi đã có Docker Compose?
  • Kubernetes architecture:
    • Control Plane: API Server, etcd, Scheduler, Controller Manager.
    • Worker Nodes: kubelet, kube-proxy, Container Runtime.
  • Core resources: Pods, Deployments, ReplicaSets, StatefulSets, DaemonSets.
  • Networking: Services (ClusterIP, NodePort, LoadBalancer), Ingress.
  • Configuration: ConfigMaps, Secrets, Resource Limits.
  • Autoscaling: HPA, VPA, Cluster Autoscaler.
  • Service Mesh: Istio, Linkerd – khái niệm và lợi ích.
  • So sánh: Kubernetes vs Docker Swarm vs AWS ECS vs Nomad.

2. CI/CD Pipeline cho Microservices

  • CI/CD concepts: Continuous Integration, Continuous Delivery, Continuous Deployment.
  • GitOps workflow: declarative infrastructure, Git as single source of truth.
  • Pipeline cho Microservices:
    • Build & test từng service độc lập.
    • Container image build & push to Registry.
    • Automated integration testing.
  • Deployment Strategies:
    • Blue-Green Deployment.
    • Canary Release (progressive rollout).
    • Rolling Update, A/B Testing.
  • Tools: GitHub Actions, GitLab CI, ArgoCD, Flux.
  • Pipeline security: SAST, DAST, container image scanning, SBOM.

3. Observability: Logging, Monitoring & Tracing

  • Ba trụ cột Observability: Logs, Metrics, Traces
    • Tại sao Monitoring alone là chưa đủ?
  • Centralized Logging:
    • ELK Stack (Elasticsearch, Logstash, Kibana)
    • Structured logging, Log aggregation, Log levels
  • Monitoring:
    • Prometheus: Pull-based metrics, PromQL basics.
    • Grafana: Dashboards, Alerting rules.
    • Golden Signals: Latency, Traffic, Errors, Saturation.
  • Distributed Tracing:
    • Jaeger, Zipkin, OpenTelemetry.
    • Trace context propagation, Span, Sampling.
  • SLO/SLI/SLA: định nghĩa, cách thiết lập, Error Budget.
  • Alerting best practices: avoid alert fatigue.

4. Security trong Microservices

  • Authentication & Authorization:
    • OAuth 2.0 flows: Authorization Code, Client Credentials.
    • OpenID Connect, JWT (structure, validation, rotation).
    • Role-Based Access Control (RBAC) & Attribute-Based Access Control (ABAC).
  • API Gateway Security: rate limiting, IP whitelisting, WAF.
  • Service-to-service security:
    • mTLS (mutual TLS), Certificate management.
    • Service Mesh security (Istio Citadel).
  • Zero Trust Architecture: nguyên lý, Never trust, always verify.
  • OWASP Top 10 cho Microservices.
  • Secrets Management: HashiCorp Vault, AWS Secrets Manager.
  • Security in CI/CD: supply chain security, image signing.

5. Hands-on Workshop: Triển khai hệ thống Microservices

  • Workshop tổng hợp: Xây dựng hệ thống Microservices hoàn chỉnh.
    • E-commerce: User Service + Product Service + Order Service + API Gateway
    • Container hóa với Docker + Docker Compose
    • Triển khai lên Kubernetes (Minikube/Kind)
    • Cấu hình Service Discovery + Health Checks
    • Tích hợp Message Queue (Kafka) cho asynchronous processing
    • Setup Monitoring cơ bản (Prometheus + Grafana)
    • Triển khai API Gateway với JWT Authentication
  • Học viên làm theo hướng dẫn step-by-step.
  • Giảng viên hỗ trợ troubleshoot real-time.
  • Review architecture decisions & code.

6. Best Practices, Anti-patterns & Q&A Tổng kết

  • Best Practices tổng hợp:
    • API Contract-first design.
    • Versioning strategies.
    • Testing strategies: Unit, Integration, Contract, Chaos.
    • Organizational patterns: Conway's Law, Team Topologies.
  • Anti-patterns phổ biến và cách tránh:
    • Distributed Monolith, Nano-services, Shared Database.
    • synchronous chains, Lack of observability.
  • Migration strategy: Monolith → Microservices roadmap.
  • Q&A mở: Trả lời mọi câu hỏi của học viên.
  • Tổng kết khóa học, lộ trình học tiếp theo.
  • Đánh giá & cấp chứng nhận.
  • Học trực tuyến

  • Học tại Hồ Chí Minh

  • Học tại Hà Nội


Các khóa học khác