Tech Vocabulary/
Lesson

Your engineering team says "we need an event busWhat is event bus?A messaging infrastructure component through which services publish events and other services subscribe to them, enabling decoupled communication." or "let's add CQRSWhat is cqrs?Command Query Responsibility Segregation - using separate models for read and write operations so each can be optimized independently.." These terms solve concrete problems: handling traffic spikes, keeping services running when parts fail, and processing millions of actions without dropping any.

Event-driven architecture: reacting to change

Instead of services calling each other directly ("Hey, do this now!"), they publish events to a central message broker:

1. Order Service: "OrderPlaced event published"
2. Payment Service: "I heard OrderPlaced, processing payment..."
3. Inventory Service: "I heard OrderPlaced, reserving stock..."
4. Notification Service: "I heard OrderPlaced, sending confirmation email..."

The order service doesn't know or care who listens. It just announces the event and moves on.

Why teams love events

  • Loose coupling: Add a new service that listens to OrderPlaced? No changes to existing code
  • Resilience: If the email service is down, the order still processes. Emails send when the service recovers
  • Scalability: Multiple instances of a service can listen to the same events, sharing the workload
  • Audit trail: Every event is logged, replay what happened for any order
Real-world example
Uber's platform is event-driven. Requesting a ride triggers matching, pricing, notifications, and trip tracking, each independently, in parallel.
02

CQRSWhat is cqrs?Command Query Responsibility Segregation - using separate models for read and write operations so each can be optimized independently.: separating reads from writes

CQRS (Command Query Responsibility Segregation) uses different models for reading and writing data.

Consider a reservation system: taking reservations (writes) is complex, prevent double-booking, check availability, collect info. Looking up reservations (reads) is simple but happens 100x more often. CQRS says: optimize separately.

When CQRS makes sense

  • Read-heavy applications: Users view content 1000 times for every 1 edit
  • Complex domains: Writing rules are complicated; reading is simple
  • Different scaling needs: Writes need strong consistency; reads can be eventually consistent

CQRS adds complexity, two data stores to keep in sync. It's overkill for simple applications but powerful for complex ones.

Good to know
True CQRS uses different data models entirely, the read model might be a flattened, denormalized view, not just a copy of the write database.
03

Message queues and event buses

These are the plumbing that makes event-driven architecture work.

A message queue is a to-do list for services. Service A adds a message; Service B picks it up when ready.

Service A: "Send welcome email to alice@example.com" → Queue
Service B (Email Service): Picks up message, sends email, deletes from queue

Benefits: buffering (queue holds 10,000 emails while the service catches up), reliability (messages persist through restarts), and load leveling (smooth out spikes). Popular systems: RabbitMQ, AWS SQS, Apache Kafka.

An event busWhat is event bus?A messaging infrastructure component through which services publish events and other services subscribe to them, enabling decoupled communication. is like a radio broadcast, one service publishes, any number of services listen:

Order Service publishes: "OrderPlaced"
↓
Payment Service hears it → processes payment
Inventory Service hears it → reserves stock
Analytics Service hears it → logs metrics

Key difference: Queues deliver to one consumer (send this email once). Event buses broadcast to many consumers (order placed triggers many reactions).

04

Load balancing: sharing the work

Load balancing distributes incoming traffic across multiple servers so no single server is overwhelmed.

Users → Load Balancer → Server 1
                    → Server 2
                    → Server 3

The load balancerWhat is load balancer?A server that distributes incoming traffic across multiple backend servers so no single server gets overwhelmed. (Nginx, HAProxy, AWS ELB) routes each request to a healthy server and continuously monitors server health, if one crashes, traffic reroutes automatically.

StrategyHow it worksBest for
Round RobinEach server takes turnsServers with equal capacity
Least ConnectionsSend to server with fewest active requestsVariable request durations
IP HashSame user always goes to same serverSession persistence
WeightedSome servers get more trafficMixed server sizes
05

High availability: staying online

High availability (HA) means your application keeps working even when things break. It's measured as uptime percentage: 99.9% allows 8.76 hours of downtime per year; 99.99% allows just 52 minutes.

HA relies on redundancy: backup systems ready to take over:

Single point of failure:     High availability:

User → Server                 User → Load Balancer → Server 1
                                                ↘ Server 2 (standby)
                                                ↘ Server 3 (standby)

HA strategies

  • Multi-zone deployment: Run in multiple data centers; if one goes down, traffic shifts
  • Database replication: Copies of data in multiple locations; replicas take over on failure
  • Auto-scaling: Add servers when traffic increases, remove when it decreases
  • Circuit breakers: Stop calling a failing service to prevent cascading failures
AI pitfall
AI tools love stacking every modern pattern into a single architecture diagram, CQRS plus event sourcing plus message queues plus circuit breakers, regardless of whether the project warrants it. Each pattern adds operational cost, and combining them all creates a system nobody on a small team can debug.
06

Putting it together

A modern e-commerce platform might combine all these concepts:

User → CDN/Load Balancer → Frontend servers (auto-scaling)API Gateway
    ├─ Catalog Service (CQRS: separate read/write models)
    ├─ Order Service (publishes events: OrderPlaced, OrderCancelled)
    ├─ Payment Service (listens for OrderPlaced)
    └─ Notification Service (serverless, triggered by events)

Message Queue: image processing, report generation
Event Bus: coordinates actions across services

These concepts solve real problems as your product grows. Event-driven architecture decouples teams. CQRSWhat is cqrs?Command Query Responsibility Segregation - using separate models for read and write operations so each can be optimized independently. optimizes for different access patterns. Message queues provide reliability. Load balancing and HA keep you online. Understanding these tradeoffs lets you participate meaningfully in architecture discussions.