Microservices & Event-Driven Architecture (EDA) Mastery

Blue-Green and Canary Deployments in K8s

1 Views Updated 5/4/2026

Advanced Deployment Strategies

A Rolling Update is good, but for mission-critical apps, you need more control. You need a way to Test in Production before you switch 100% of the traffic.

1. Blue-Green Deployment

You have two identical environments: Blue (Old) and Green (New). You deploy V2 to Green, test it thoroughly, and then flip the Load Balancer switch to point to Green. If anything fails, you flip it back to Blue instantly. **Cons:** Twice the infrastructure cost.

2. Canary Deployment

You deploy V2 to just 1% of your users. You monitor the error rates and performance. If it's stable, you go to 10%, 50%, and finally 100%. This is the safest way to release, as it limits the 'Blast Radius' of any hidden bugs.

3. Flag-based Rollouts

Combine Canary deployments with **Feature Flags**. You ship the code, but the feature is "Off." You then turn it "On" for internal users first, then specific 'Beta' users. This decouples 'Deployment' (moving code) from 'Release' (turning on features).

4. Interview Mastery

Q: "How do you handle 'Schema Changes' during a Blue-Green deployment?"

Architect Answer: "The database must be **Backward Compatible**. You can never delete a column or rename it in one step. You must use the **Expand-and-Contract** pattern: 1. Add the new column. 2. Deploy V2 (which writes to both). 3. Backfill old data. 4. Deploy V3 (which only uses the new column). 5. Delete the old column. This ensures that during the 'Green' phase, the 'Blue' app doesn't crash when it sees the new schema."

Microservices & Event-Driven Architecture (EDA) Mastery
1. Foundations of Microservices
The Monolith to Microservices transition: When and why? Domain Driven Design (DDD): Bounded Contexts and Aggregates Database Per Service: Managing data consistency Service Discovery and Health Checks in .NET
2. Communication Patterns
Synchronous Communication: HTTP/gRPC and Service Mesh Asynchronous Communication: Message Brokers (RabbitMQ/Kafka) API Gateways: YARP (Yet Another Reverse Proxy) vs Ocelot Protobuf and Shared Contracts: Managing breaking changes
3. Event-Driven Architecture (EDA)
Introduction to EDA: Producers, Consumers, and Topics The Publisher/Subscriber Pattern in .NET Event Sourcing: Capturing every state change CQRS (Command Query Responsibility Segregation) with MediatR
4. Distributed Transactions & Resiliency
The Saga Pattern: Orchestration vs Choreography The Outbox Pattern: Ensuring reliable message delivery Idempotency: Preventing duplicate message processing Distributed Locking with Redis (Redlock)
5. Observability & Monitoring
Distributed Tracing with OpenTelemetry Centralized Logging: ELK Stack (Elasticsearch, Logstash, Kibana) Metrics and Dashboards: Prometheus and Grafana Correlation IDs: Tracking requests across services
6. Security & Identity
Centralized Authentication: IdentityServer4 & Duende Identity OAuth2 and OIDC Flow for Microservices API Key Management and Rate Limiting Mutual TLS (mTLS) for Internal Service-to-Service Security
7. Infrastructure & Deployment
Containerization: Production-grade Dockerfiles Kubernetes for .NET: Pods, Services, and Ingress Helm Charts: Managing complex deployments Blue-Green and Canary Deployments in K8s
8. FAANG Microservices Case Studies
Case Study: Designing a Global Notification Engine (Reliability at Scale) Case Study: Building a High-Performance Logging Pipeline (PB/Day)