欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

RabbitMQ调优系列2 为大量连接进行调整

程序员文章站 2022-06-08 22:06:08
...
RabbitMQ调优系列2   为大量连接进行调整


Some workloads, often referred to as "the Internet of Things", assume a large number of client connections per node, and a relatively low volume of traffic from each node. One such workload is sensor networks: there can be hundreds of thousands or millions of sensors deployed, each emitting data every several minutes. Optimising for the maximum number of concurrent clients can be more important than for total throughput.
【有些工作负载(通常称之为“物联网”)假定每个服务器节点有大量的客户端连接,并且每个节点的流量相对较低。像这样的工作负载比如传感器网络:部署的传感器可能有数十万或数百万个,每几分钟发送一次数据。优化并发客户端连接的最大数量比优化总吞吐量更重要。】

Several factors can limit how many concurrent connections a single node can support:
【通常有以下几个因素可以限制单个节点支持的并发连接数:】
  • Maximum number of open file handles (including sockets) as well as other kernel-enforced resource limits
  • Amount of RAM used by each connection
  • Amount of CPU resources used by each connection
  • Maximum number of Erlang processes the VM is configured to allow

  • 操作系统可打开的文件句柄(包括套接字)的最大数量以及其他内核强制资源限制的最大数量
  • 每个连接使用的RAM大小
  • 每个连接使用的CPU资源
  • Erlang虚拟机允许配置的最大Erlang进程数

  • 一、限制打开的文件句柄数量

    Most operating systems limit the number of file handles that can be opened at the same time. When an OS process (such as RabbitMQ's Erlang VM) reaches the limit, it won't be able to open any new files or accept any more TCP connections.
    【很多操作系统都限制了在同一时刻可打开的文件句柄数量。当一个操作系统进程(例如RabbitMQ的 Erlang VM进程)达到了该限制,那么该进程将不能够打开任何新的文件或者接受更多的TCP连接。】

    How the limit is configured varies from OS to OS and distribution to distribution, e.g. depending on whether systemd is used. For Linux, Controlling System Limits on Linux in our Debian and RPM installation guides provides. Linux kernel limit management is covered by many resources on the Web, including the open file handle limit.

    With Docker, Docker daemon configuration file in the host controls the limits.

    MacOS uses a similar system.

    On Windows, the limit for the Erlang runtime is controlled using the ERL_MAX_PORTS environment variable.

    When optimising for the number of concurrent connections, making sure your system has enough file descriptors to support not only client connections but also files the node may use. To calculate a ballpark limit, multiply the number of connections per node by 1.5. For example, to support 100,000 connections, set the limit to 150,000. Increasing the limit slightly increases the amount of RAM idle machine uses but this is a reasonable trade-off.