Skip to content

How should I handle redis' auto-ulimit? #2027

Closed

Description

@lusitania

On Ubuntu Trusty/64 in /var/log/redis/redis-server.log

Unable to set the max number of files limit to 10032 (Operation not permitted), setting the max clients configuration to 3984.

What do I need to do to eliminate the error message? Allow redis-server to alter its ulimit accordingly (by adding some nifty sudoers rule)? Or place a custom config in

/etc/security/limits.d/myredis.conf:

@redis hard nofile 10032

What do you recommend?

Activity

  1. mattsta commented on Sep 25, 2014

    @mattsta
    Contributor

    You'll want the user who starts your Redis process to have permission to increase the ulimit to something larger. You can edit your limits conf to allow the user running Redis a larger default (or larger upper limit), or you can manually set it in a launch script before Redis starts since ulimit is inherited by children (ulimit -n 65535; redis-server).

    If you run Redis as root (not recommended), it will set the ulimit correctly, but Redis doesn't drop permissions, so you'd be running Redis as root forever.

  2. lusitania commented on Sep 25, 2014

    @lusitania
    Author

    I see. So it would be safefor me to use this limits change?

    @redis hard nofile 65535
    @redis soft nofile 10032
    

    The daemon is running as redis:redis by default on Ubunty Trusty. I don't want to touch that.

  3. mattsta commented on Sep 25, 2014

    @mattsta
    Contributor

    That looks like it should work.

    The reason for the near 10,000 limit is because by default Redis limits the number of connected clients to 10,000 (maxclients 10000). If you increase your maxclients number, you'll need to set more allowed open files.

  4. lusitania commented on Sep 25, 2014

    @lusitania
    Author

    Turns out Ubuntu won't allow any ulimit assignments by non-root users even if the limits.conf was changed (and the two /etc/pam.d/common-session* contain a session required pam_limits.so).

    I guess the Ubuntu way is to uncomment /etc/default/redis-server and add/change its single value to ULIMIT=10032 as you recommended earlier.

    IMO Ubuntu is nasty here but I see no other way other than to document it as quirk/hack. It would be nice if you could find a proper place for this detail... maybe in your FAQ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions