NOTE
Designing a High-Concurrency System
A historical note on scalability, service and storage scaling, and approaches for read- and write-heavy concurrency.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is Scalability?
- It describes a system’s ability to handle increasing load.
- Load refers to concurrency: Performance Testing
2. How to Design a Scalable System
- Vertical scaling.
- Horizontal scaling.
3. What Is High Concurrency?
- A system with high read QPS, write QPS, or both.
4. How to Design for High Concurrency
4.1. Service-Layer Scalability
- Make performance grow roughly linearly by adding machines: each service should be stateless, meaning there should not be business logic that must run on one specific node.
- In other words: add machines + load balancing.
4.2. Storage Scalability
- Enable replication + partitioning in the underlying components.
- MySQL primary-replica replication for read/write splitting + database/table sharding: MySQL Primary-Replica Replication
- Redis Cluster: Redis Cluster
- ZooKeeper does not work for this: Cluster Architecture.md
- Elasticsearch cluster: Elasticsearch
- RabbitMQ mirrored replication: RabbitMQ Cluster Mode.md
- Kafka replication + partitioning: Kafka Architecture.md
4.3. High Read Concurrency
Essentially solved through the idea of replication.
4.3.1. Cache
4.3.2. Heavier Writes, Lighter Reads
- Replace read fan-out with write fan-out.
4.3.3. Read/Write Splitting
4.4. High Write Concurrency
4.4.1. Asynchronous Processing
- How to Design an Asynchronous System
- Kafka can absorb a wave of traffic first.
4.4.2. Cache + Batch Processing
- How to Design a Cache System
- Cache tasks or data in an in-memory queue and then process them in batches.
4.4.3. Heavier Reads, Lighter Writes
- Replace write fan-out with read fan-out.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub