Package: redis-server Severity: wishlist Tags: upstream patch Redis-server runs with its own user and has no builtin way to bypass the maximum number of opened file descriptors (1024 by default). This prevents its use in a high concurrency environment.
To override this, a patch has been written so that Redis set its limits, based on its maxclients configuration : https://github.com/antirez/redis/commit/58732c23d53d6fc652668a516556ea182b0ed0f8 But it requires Redis to run as root... No way. Then, I decided to consider the maxclients directive and to run the appropriate "ulimit -n" directly in the init script. See the attached patch. Note : * The patch has been tested with dash and bash * The 32 FD offset is explained in the above link
diff -urN redis.orig/debian/control redis/debian/control --- redis.orig/debian/control 2012-05-12 16:01:58.000000000 +0200 +++ redis/debian/control 2012-05-12 16:03:55.000000000 +0200 @@ -10,7 +10,7 @@ Package: redis-server Architecture: any -Depends: ${misc:Depends}, ${shlibs:Depends}, adduser +Depends: ${misc:Depends}, ${shlibs:Depends}, adduser, awk Description: Persistent key-value database with network interface Redis is a key-value database in a similar vein to memcache but the dataset is non-volatile. Redis additionally provides native support for atomically diff -urN redis.orig/debian/redis-server.init redis/debian/redis-server.init --- redis.orig/debian/redis-server.init 2012-05-12 16:01:58.000000000 +0200 +++ redis/debian/redis-server.init 2012-05-12 16:07:04.000000000 +0200 @@ -25,6 +25,11 @@ set -e +maxclients=$(awk '/^[ \t]*maxclients[ \t]/ { print $2 }' /etc/redis/redis.conf) +if [ ! -z $maxclients ] && [ $maxclients -gt 992 ] ; then + ulimit -n $((maxclients+32)) +fi + case "$1" in start) echo -n "Starting $DESC: "