> For the complete documentation index, see [llms.txt](https://maxwell.gitbook.io/way-to-architect/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maxwell.gitbook.io/way-to-architect/xi-tong-she-ji/xian-liu/jie-ru-ceng-xian-liu.md).

# 接入层限流

接入层通常是指流量的入口，该层的主要功能：负载均衡、非法请求过滤、请求聚合、缓存、降级、限流、A/B测试、服务质量监控等。

对于Nginx接入层限流，可以使用Nginx自带的两个模块和OpenResty提供的限流模块：

* **连接数限流模块ngx\_http\_limit\_conn\_module**，可以对某个key对应的总的网络连接数进行限流，可以按照IP/域名等维度。
* **请求限流模块（漏桶算法）ngx\_http\_req\_module**，可以对某个key对应的请求的平均速率进行限流，有两种模式：平滑模式（delay）和允许突发模式（nodelay）。
* **Lua限流模块lua\_resty\_limit\_traffic**，可以通过编程来根据更为复杂的业务场景进行动态限流处理。
