Chapter 7 – Distributed Architecture
Most applications start simple: one database, one API, and a front-end. It works fine at first — but as the product grows and complexity rises, one single…
Most applications start simple: one database, one API, and a front-end. It works fine at first — but as the product grows and complexity rises, one single service can’t handle it all.
That’s where distributed architecture comes in: a set of patterns and practices to split responsibilities across multiple services, connected through events, queues, and communication protocols.
⚙️ What is distributed architecture?
In simple terms: it’s when you break a system into independent parts, each responsible for a single function, and make them communicate reliably.
Common approaches:
-
Microservices: small, specialized services communicating via APIs or messaging.
-
Event-driven systems: reacting to events and propagating state asynchronously.
-
CQRS + Event Sourcing: separating reads and writes while keeping a full historical log.
💡 Why go distributed?
Scalability – Scale only what’s necessary.
Example: 90% of traffic happens in “checkout”; scale just that.
Resilience – A failure in one service shouldn’t crash the whole system.
Example: if recommendations fail, customers can still buy.
Flexibility – Teams can evolve their services independently.
🛒 Practical example: a marketplace
Think of a marketplace like Amazon or Mercado Livre. It can be split into:
-
Catalog
-
Cart
-
Checkout
-
Notifications
-
Delivery
If everything were monolithic, any change to “delivery” would require redeploying the entire system. In a distributed design, each module evolves independently under shared communication standards.
🧩 Core patterns
⚠️ Common pitfalls
Distributing too early: Startups often over-engineer before finding product-market fit, wasting time and money.
Fake independence: Services that share the same database aren’t truly decoupled.
Lack of governance: Without consistent authentication, contracts, and monitoring, chaos emerges fast.
🐜 Metaphor: the ant colony
A monolith is like one ant carrying the world. A distributed system is an ant colony, every ant plays its role, but all cooperate toward one mission.
The Staff Engineer is the architect ensuring the colony stays resilient and coordinated.
🧠 Practical exercise
Pick a system you know and ask:
-
Which modules could become standalone services?
-
Which communications should be synchronous vs. asynchronous?
-
What happens if one service goes down?
-
Do you have single points of failure?
💬 Staff Insight
“Distributed architecture isn’t about pretty microservices. It’s about building systems that stay standing when parts fail.”
🧭 Practical checklist
-
Are my services truly independent or just appear to be?
-
Have I defined clear communication standards (REST, gRPC, events)?
-
Do I have full observability across services?
-
Can I scale individual parts of the system?
-
Do I know my architecture’s weakest point?
👉 In this chapter, you learned to design scalable, resilient distributed systems. Next, we’ll dive into FinOps and cost efficiency — because beautiful architecture means little if it’s too expensive to run.