我需要configuration服务器来处理超过100万个打开的websocket连接(最好是200万)。
我使用这个博客的configuration:
sysctl -w fs.file-max=12000500 sysctl -w fs.nr_open=20000500 ulimit -n 20000500 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000' sysctl -w net.ipv4.tcp_rmem='1024 4096 16384' sysctl -w net.ipv4.tcp_wmem='1024 4096 16384' sysctl -w net.core.rmem_max=16384 sysctl -w net.core.wmem_max=16384
但是,我的应用程序达到469219连接后,停止应用新的连接。 我错过了什么? 我真的觉得在操作系统configuration中缺less一些东西。 我们的主要应用程序是用Java(用Tomcat服务器)编写的,但是我也得到了与NodeJS服务器非常相似的结果。
我们使用Ubuntu的16GB内存。
编辑:在最高系统使用约14GB的12Gb。
UPD :
所以最后我有32GB的工作站。 问题通过增加RAM空间来解决。 目前使用18GB Java堆,我能够处理567K WS连接。 对于更高的数字,我需要更多的客户:-)
不一定是答案,但太大,不能发表评论。
tcp_mem (since Linux 2.4) This is a vector of 3 integers: [low, pressure, high]. These bounds, measured in units of the system page size, are used by TCP to track its memory usage. The defaults are calculated at boot time from the amount of available memory. (TCP can only use low memory for this, which is limited to around 900 megabytes on 32-bit systems. 64-bit systems do not suffer this limi- tation.) low TCP doesnât regulate its memory allocation when the number of pages it has allocated globally is below this number. pressure When the amount of memory allocated by TCP exceeds this number of pages, TCP moderates its memory consumption. This memory pressure state is exited once the number of pages allocated falls below the low mark. high The maximum number of pages, globally, that TCP will allocate. This value overrides any other limits imposed by the kernel.
请注意以下几点:
这些边界是以系统页面大小为单位度量的
将该值设置为10000000 10000000 10000000表示内核使用TCP的内存为39062 MiB。 几乎三倍你有。
第二个问题是TCP rmem的3个值,你设置的wmem定义了min,default和max。 考虑到你的tcp_memconfiguration状态,你永远不会进入“内存节省”模式,我想你实际上分配在每个sockets4-16k之间。
所以,如果我是内核,而且看到这种疯狂的设置,那么我可能不会那么可预测地performance出来。
尝试将此值降低到实际可以使用的值并再次尝试。
最后,我会指出,如果你认真地相信你生活在梦想世界里,
即使在最好的情况下(使用epoll集),在epoll集中的200万个条目也是昂贵的。 这是永远不会发生与工人或prefork模型。
你需要更平均地分散这个载荷。 您可能至less需要另外10个节点来获得任何值得用户称为服务的东西。