posts - 496,comments - 227,trackbacks - 0
http://stackoverflow.com/questions/29358313/max-mqtt-connections?answertab=votes#tab-top


4
3

i have a need to create a server farm that can handle 5 million connections, 5 million topics (one per client), process 300k messages/sec.

i tried to see what various message brokers were capable so i am currently using two rhel ec2 instances (r3.4xlarge) to make lots of available resources. so you do not need to look it up, it has 16vcpu, 122gb ram. i am nowhere near that limit in usage.

i am unable to pass the 600k connections limit. since there doesn't seem to be any o/s limitation (plenty of ram/cpu/etc.) on either the client nor the server what is limiting me?

i have edited /etc/security/limits.conf as follows:

* soft  nofile  20000000 * hard  nofile  20000000  * soft  nproc  20000000 * hard  nproc  20000000  root  soft  nofile 20000000 root  hard  nofile 20000000 

i have edited /etc/sysctl.conf as follows:

net.ipv4.ip_local_port_range = 1024 65535   net.ipv4.tcp_tw_reuse = 1  net.ipv4.tcp_mem = 5242880  5242880 5242880  net.ipv4.tcp_tw_recycle = 1  fs.file-max = 20000000  fs.nr_open = 20000000  net.ipv4.tcp_syncookies = 0  net.ipv4.tcp_max_syn_backlog = 10000  net.ipv4.tcp_synack_retries = 3  net.core.somaxconn=65536  net.core.netdev_max_backlog=100000  net.core.optmem_max = 20480000 

for apollo: export apollo_ulimit=20000000

for activemq:

activemq_opts="$activemq_opts -dorg.apache.activemq.usededicatedtaskrunner=false" activemq_opts_memory="-xms50g -xmx115g" 

i created 20 additional private addresses for eth0 on the client, then assigned them: ip addr add 11.22.33.44/24 dev eth0

i am fully aware of the 65k port limits which is why i did the above.

  • for activemq i got to: 574309
  • for apollo i got to: 592891
  • for rabbit i got to 90k but logging was awful and couldn't figure out what to do to go higher although i know its possible.
  • for hive i got to trial limit of 1000. awaiting a license
  • ibm wants to trade the cost of my house to use them - nah!
    
asked mar 30 '15 at 23:52
10311
   
can't really tell how to increase the throughput. however, checkout  . not sure about the mqtt support, but it seems capable of extrem throughput / # clients. –  mar 31 '15 at 7:52
   
did you try mosquitto? () –  apr 2 '15 at 8:02
   
trying hive, apollo, mosquito, active, rabbit, mosquito –  apr 2 '15 at 21:58

1 answer

2accepted

answer: while doing this i realized that i had a misspelling in my client setting within /etc/sysctl.conf file for: net.ipv4.ip_local_port_range

i am now able to connect 956,591 mqtt clients to my apollo server in 188sec.


more info: trying to isolate if this is an o/s connection limitation or a broker, i decided to write a simple client/server.

the server:

    socket client = null;     server = new serversocket(1884);     while (true) {         client = server.accept();         clients.add(client);     } 

the client:

    while (true) {         inetaddress clientiptobindto = getnextclientvip();         socket client = new socket(hostname, 1884, clientiptobindto, 0);         clients.add(client);     } 

with 21 ips, i would expect 65535-1024*21 = 1354731 to be the boundary. in reality i am able to achieve 1231734

[root@ip ec2-user]# cat /proc/net/sockstat sockets: used 1231734 tcp: inuse 5 orphan 0 tw 0 alloc 1231307 mem 2 udp: inuse 4 mem 1 udplite: inuse 0 raw: inuse 0 frag: inuse 0 memory 0 

so the socket/kernel/io stuff is worked out.

i am still unable to achieve this using any broker.

again just after my client/server test this is the kernel settings.

client:

[root@ip ec2-user]# sysctl -p net.ipv4.ip_local_port_range = 1024     65535 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 5242880      5242880 15242880 net.ipv4.tcp_tw_recycle = 1 fs.file-max = 20000000 fs.nr_open = 20000000  [root@ip ec2-user]# cat /etc/security/limits.conf * soft  nofile  2000000 * hard  nofile  2000000     root  soft  nofile 2000000 root  hard  nofile 2000000 

server:

[root@ ec2-user]# sysctl -p net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 5242880      5242880 5242880 net.ipv4.tcp_tw_recycle = 1 fs.file-max = 20000000 fs.nr_open = 20000000 net.ipv4.tcp_syncookies = 0 net.ipv4.tcp_max_syn_backlog = 1000000 net.ipv4.tcp_synack_retries = 3 net.core.somaxconn = 65535 net.core.netdev_max_backlog = 1000000 net.core.optmem_max = 20480000 
posted on 2016-06-01 16:15 simone 阅读(866) 评论(0)  编辑  收藏 所属分类: java
"));
网站地图