Microservices
A microservices architecture splits an application into many small, independent services. Each service runs in its own process and owns its own deploy. Services communicate over the network, usually via HTTP APIs or message queues. From ECE459 L10.
Why?
Monoliths stop scaling past a certain size. Deploys get painful, teams step on each other, one crash takes everything down. Splitting by domain boundary (user service, payment service, etc.) lets teams and features scale independently.
What microservices encourage
- Separation of concerns (modularity, encapsulation)
- Horizontal scaling and workload partitioning
- On-demand provisioning, automated ops
Don't jump to microservices
L10’s advice: start with a monolith. Only split off services once it proves valuable. “Start with microservices so we can scale each part independently” sounds good, but you may never need it.
Pitfalls from L10
- Excessive network calls. Every service call is a network hop. Latency adds up fast on chatty APIs
- N+1 queries. Fetch list, then query each item one by one; see N+1 Problem
- Chokepoints. Central auth, shared DBs, hot infra become bottlenecks. JWTs avoid a central auth chokepoint the way a passport lets border agents validate without phoning the issuing country
- Over-taking responsibility. Search/filter in the app when the DB could; render on backend when frontend could. Put work where the data already lives
- Too much waiting. Sync RPCs block. Switch to async I/O or channels when a thread would otherwise be parked
Analogy from the Netflix guide
Breaking an application into components is like modular vs end-to-end robotics. End-to-end systems are hard to debug because everything is tightly coupled. Microservices give you seams to inspect and swap.
Connection to microkernels
Microservices and microkernels are both modular but apply to different domains. Microservices decompose an application into independent services. Microkernels provide a minimal OS core with extras in user space.
More context in Production Environment.
Resources:
- Mastering Chaos: A Netflix Guide to Microservices
- Fallacies of Distributed Computing
- Debugging microservices: the User-Agent header