Reputation: 1497
I am using the redis pub/sub mechanism in my application and would like to do a benchmark test. I have an I-7 machine with 32 GB RAM and ulimit set to 1024. Redis server is of same configuration except for ulimit set to 65535. How many simultaneous connections I can make without redis complaining about MAXClient reached exception. I tried tuning the connection with connection pooling etc but number of simultaneous request does not seem to go beyond 25K requests.
Thanks \
Upvotes: 2
Views: 9882
Reputation: 11
Solution that worked for me: Edited /etc/systemd/system/redis.service Added the following line to the [Service] section
LimitNOFILE=110000
Upvotes: 1
Reputation: 251
I don't have idea about pub/sub connections, but what I have done is explained here, I think it may help you.
I set In redis.conf file "maxclient" property set with 27000 connection.
Then I run the benchmark utility provided by redis with -c 27000 means 27000 parallel connection. But this will not work directly as ulimit -Sn is 1024 by default in ubuntu. So I change -Sn and -Hn with 65535.
The redis has client server architecture so we can not make too many client connection from one computer. So we need to reuse the connection and for that execute bellow command sudo echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
then after I am able to run benchmark util with -c 29000 connection. then after I was not able to execute this util with more client, but but I get the error of
Could not connect to Redis at 127.0.0.1:7000: Cannot assign requested address
Still I was not reach with max connection, so I run the same benchmark util with 3 separate computer each with 29000 parallel client and it works and get executed.
The strange thing is my redis.conf has maxclient 27000 set, still I am able to connect 87000 client.
Upvotes: 1
Reputation: 6870
Maximum number of clients
In Redis 2.4 there was an hard-coded limit about the maximum number of clients that was possible to handle simultaneously.
In Redis 2.6 this limit is dynamic: by default is set to 10000 clients, unless otherwise stated by the maxmemory directive in Redis.conf.
However Redis checks with the kernel what is the maximum number of file descriptors that we are able to open (the soft limit is checked), if the limit is smaller than the maximum number of clients we want to handle, plus 32 (that is the number of file descriptors Redis reserves for internal uses), then the number of maximum clients is modified by Redis to match the amount of clients we are really able to handle under the current operating system limit.
When the configured number of maximum clients can not be honored, the condition is logged at startup as in the following example:
$ ./redis-server --maxclients 100000
[41422] 23 Jan 11:28:33.179 # Unable to set the max number of files limit to 100032 (Invalid argument), setting the max clients configuration to 10112.
When Redis is configured in order to handle a specific number of clients it is a good idea to make sure that the operating system limit to the maximum number of file descriptors per process is also set accordingly.
Under Linux these limits can be set both in the current session and as a system-wide setting with the following commands:
ulimit -Sn 100000 # This will only work if hard limit is big enough.
sysctl -w fs.file-max=100000
Upvotes: 2