# Scalability - Harvard lecture

> <https://www.youtube.com/watch?v=-W9F__D3oY4>

## Vertical Scaling

* CPU: cores, L2 cache
* Disk
* RAM

## Horizontal Scaling

* multiple servers
* then we need to distribute requests - load balancer

## load balancer

* round robin is not so good if there's some heavy users in specific server
* RAID (redundant array of independent disks) - RAID works by placing data on multiple disks and allowing input/output (I/O) operations to overlap in a balanced way, improving performance. Because the use of multiple disks increases the mean time between failures (MTBF), storing data redundantly also increases fault tolerance.
* Software: ELB, HAProxy
* Hardware

## Sticky sessions - 断电之类的 single failure

* shared storage
* cookies

## Caching

* .html
* MySQL Query Cache
* memcached

## Replication

* Master-slave
* Master-master
