Patterns for Scalability and Reliability in Systems


Agenda

  1. Client Server Architecture
  2. Scalability Patterns
  3. Limitations
  4. Extending Client Server Architecture
  5. Availability/Reliability Patterns
  6. Conclusion

Client Server Architecture

w:900


Scalability Patterns

1. Load Balancing

Problem: I have too many requests! My single server can't take it anymore ๐Ÿ˜ญ

Solution: Horizontal scaling with a load balancer -- distribute requests across multiple servers

w:900px


Scalability Patterns

2. Caching

Problem: My database is slow and can't handle all these reads ๐Ÿ˜ฉ

Solution: Cache frequently/recently accessed data to reduce database load

w:900px


Scalability Patterns

3. Database Sharding/Partitioning

Problem: My database is massive and can't handle all these writes ๐Ÿ˜ญ

Solution: Split the database into smaller, more manageable pieces. Designate a partition key to determine which shard to write to.

w:900p


Scalability Patterns

3. Queueing

Problem: My system is overwhelmed by bursty traffic and can't process requests fast enough ๐Ÿ˜ฉ

Solution: Use a message queue to manage requests and process them asynchronously

w: auto h: 400px


Limitations

SQL Databases

Problem: SQL databases have limitations on scalability due to ACID properties ๐Ÿ˜ž

Solution: Add replicas, shard, or use a different database


Limitations

NoSQL Databases


Limitations

Networks

Problem: At scale, network latency and throughput can become a bottleneck ๐Ÿ˜ฑ

Solution: Add more servers and route network traffic, use CDNs/edge caching


Limitations

Single Hosts

Problem: Single hosts have limitations on CPU, memory, and disk I/O ๐Ÿ˜ก

Solution: Partition for write-heavy workloads, cache data upstream for read-heavy workloads to decrease requests


Service-Oriented Architecture (SOA)

Problem: My monolithic architecture is hard to maintain and scale ๐Ÿ˜–

Solution: Break down the monolith into smaller, more manageable services. Each service is responsible for a specific task and can be scaled independently.

w:900px


Extending Client Server Architecture

API Gateway

Problem: I have multiple services which are non-uniform, and clients need to access them all ๐Ÿ˜ฉ

Solution: Use an API Gateway to route requests to the appropriate service


Availability/Reliability Background

Why do we need a reliable system?

To put it into perspective, AWS EC2's Service Level Agreement is 99.99% uptime, which allows for 52.56 minutes of downtime per year

So building on top of cloud services still requires going the extra mile to ensure reliability


Reliability Patterns

1. Replication

Problem: I have a stateful, purpose-built service that needs to be highly available ๐Ÿ˜…

Solution: Primary forwards writes to replicas, which can take over if the primary fails


Reliability Patterns

2. Circuit Breaker


Reliability Patterns

3. Graceful Degradation

Design systems to maintain (at least) partial functionality during failures - If a service is down, show cached data - If a service is overloaded, timeout gracefully and retry later

Limit hard dependencies and keep services decoupled


Questions?