Scalable Distributed Systems
To design a good distributed system, we must consider:
- Scalability: aggregation of compute, storage, memory & bandwidth.
- Location transparency: client doesn't care which server handles request.
- High availability: mask hardware & software failures.
- Composable services: Rely on composition of independent services.
1. Data Centers
A large group of networked servers, built from commodity hardware. We scale out, not up. Software is designed for failure. They provide economies of scale.
They also allow elasticity: the ability to dynamically adjust resources based on demand.
2. Design Principles
A scalable system may be classified based on its response time:
- Online Systems (
) - Batch Processing Systems (
) - Nearline Systems (
to ) - dynamic content presented to users where freshness matters. For example, recommendation, dashboards, ad targeting, etc.
Some design principles include:
- Stateless Services: data consistency is hard, so avoid this by making services stateless. For example, HTTP.
- Caching: allows reducing latency.
- Partition / Aggregation Pattern: allows dividing data into smaller chunks and processing them in parallel across multiple backends.
- Different Consistency Models: scalability is often lmited by the overhead in managing state consistency across backends. Do we always need strong consistency?
- Efficient Failure Recovery: full redundancy is too expensive, so we need to design efficiently for failure. You could replicate or even recompute.