Microservice
Amazon ECS / EKS / AWS Lambda
A small, independently deployable service that owns one business capability and its data.
In a monolith
A module inside the app
Before extraction it’s a package inside the monolith, called with function calls and sharing the app’s database.
In a distributed system
Own deploys, own data
Runs and scales independently, talks to others over HTTP/gRPC or events, and ideally owns its database — nobody else reads its tables.
On AWS
Amazon ECS / EKS / AWS Lambda
Containers on ECS (Fargate or EC2) or EKS; small event-driven services on Lambda. Discovery through an internal ALB, Cloud Map or ECS Service Connect.
- ECS on Fargate$$No servers to manage — a good default for containers
- EKS (Kubernetes)$$$Maximum flexibility and ecosystem, most operational overhead
- Lambda$Scales to zero, absorbs spikes; cold starts, 15-minute max, watch DB connections
- EC2 Auto Scaling group$$VMs per service; more ops work
- Reach for it when
- Teams block each other in one codebase, or one capability needs very different scaling, availability or deploy cadence.
- What it costs you
- Every call is a network call: latency, timeouts, partial failure
- Cross-service transactions become sagas and eventual consistency
- Ops overhead per service: CI/CD, dashboards, versioned APIs
- When it dies
- Only this capability should go down — if callers use timeouts/circuit breakers or call it asynchronously. Without those, one slow service cascades into every caller.
Interview follow-ups
How do services find each other?
Service discovery: names resolved through a registry (Cloud Map), an internal load balancer per service, or a service mesh.
How do you keep data consistent across services?
Each service owns its data; cross-service workflows use sagas (orchestrated or event-driven) and the outbox pattern so the DB write and the event can’t diverge.
Sync or async between services?
Sync (HTTP/gRPC) when the caller needs the answer now; async events when it doesn’t — async decouples availability and absorbs spikes.
Connection rules
It talks to
- Load balancer
- NAT gateway
- App server
- Service
- Realtime server
- Workflow
- SQL database
- Read replica
- NoSQL store
- Cache
- Object storage
- Search
- DB proxy
- Queue
- Pub/sub topic
- Event stream
- Identity provider
- Secrets
- Third-party API
- API gatewayOnly when: Calling another team’s public API or a partner API that only exists behind a gateway.
Gets traffic from
- DNS
- CDN
- Load balancer
- API gateway
- App server
- Worker
- Scheduler
- Realtime server
- Workflow
- Queue
- Pub/sub topic
- Event stream
- ClientsOnly when: There is exactly one instance (early stage: DNS points at the server). With two or more instances, put a load balancer or gateway in front so clients don’t need to know which server to hit.
- DLQOnly when: A separate consumer that inspects or replays failed messages — usually manual or alarm-driven.
- Third-party APIOnly when: A single-instance webhook receiver; normally webhooks come in through your LB or gateway.
Never
- Service → CDNYour code doesn’t send traffic to the CDN — the CDN pulls from origins.
- Service → WorkerDon’t call workers directly — enqueue a job.
- Service → DLQProducers publish to the main queue; the broker moves failures to the DLQ.