Scaling
Web server Scaling
- vertical scaling(scale up) : adding more power(CPU, RAM)
- π‘ When traffic is low, vertical scaling is a great option
- β
simplicity
- β has a hard limit, it is impossible to add unlimited CPU and memory
- β does not have failover and redundancy
- horizontal scaling(scale out): adding more services into your poll of resources
- π‘ for large scale applications due to the limitations of vertical scaling
- β
failover and redundancy
- β difficult
Database Scaling
- vertical scaling(scale up) : adding more power(CPU, RAM)
- π‘ When traffic is low, vertical scaling is a great option
- Amazon RDS 24 TB of RAM . For example, stackoverflow.com in 2013 had over 10 million monthly unique visitors, but it only had 1 master database
- β
simplicity
- β has a hard limit, it is impossible to add unlimited CPU and memory
- β does not have failover and redundancy
- β The overall cost of vertical scaling is high. Powerful servers are much more expensive
- horizontal scaling(sharding): adding more services into your poll of resources
- π‘ for large data due to the limitations of vertical scaling
- π‘sharding key examples- user_id % 4
- When choosing a sharding key, one of the most important criteria is to choose a key that can evenly distributed data.
- β
failover and redundancy
- β complexity and new challenges
- Resharding data
- Celebrity problem.To solve this problem, we may need to allocate a shard for each celebrity. Each shard might even require further partition.
- Join and de-normalization. A common workaround is to de- normalize the database so that queries can be performed in a single table.