# 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liuzhenglaichn.gitbook.io/system-design/basics/load-balancing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
