- Vertical scaling - scale up - -> add more power: CPU, RAM, etc ... -> hard limit, note have failover and redundancy
- Horizontal scaling
Load balancer
Database replication : Master <- write, 3 Slave <-read
Cache > consider: data read frequently but modified infrequently -> synced cache, expiration policy, consistency -> data store and cache in sync, mitigating failures SPOF, eviction policy -> full cache LRYS, LFU, FIFO...
CDN -> consider : cost, setting cache, CDN fallback, invalid files Stateless web tier: move the state out of web tier -> NOSQL, stateful architecture (remember client data), stateless architecture
Datacenter: sync data, test deploy, traffic redirection
MSG queue -> background worker
Loggin, metrics, automation
Data scaling : scale up (RAM, MEM), scale-out -> sharding
Scaling a system is an iterative process. Iterating on what we have learned in this chapter could get us far. More fine-tuning and new strategies are needed to scale beyond millions of users. For example, you might need to optimize your system and decouple the system to even smaller services. All the techniques learned in this chapter should provide a good foundation to tackle new challenges. To conclude this chapter, we provide a summary of how we scale our system to support millions of users:
• Keep web tier stateless
• Build redundancy at every tier
• Cache data as much as you can
• Support multiple data centers
• Host static assets in CDN
• Scale your data tier by sharding
• Split tiers into individual services
• Monitor your system and use automation tools