> For the complete documentation index, see [llms.txt](https://liuzhenglaichn.gitbook.io/system-design/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuzhenglaichn.gitbook.io/system-design/basics/load-balancing.md).

# Load Balancing

![](/files/-M9omHqAbOQ34mpNwkse)

* Client to gateway: DNS parse domain to different ip addresses. (If we have multiple data centers, DNS will find the geographically closest data center)
* Gateway to web server: reverse proxy
* web server to application server: connection pool
* database load balancing: partition / sharding

How to distribute traffic:

* random, round-robin
* min connection count
* min latency
* based on ip.

## What if load balancer crashed?

TODO
