Question

I have seen a small amount of discussion here and there about setting ulimit -n (file handles) in Linux when using Node. Default on most linux distros is 1024. I can find no recommendations anywhere. Normally for apache you'd set it pretty high. Any thoughts on this? Easy to set it high to start with, but not sure there is a need. We are using Mongo remotely, not opening a lot of files locally.

Was it helpful?

Solution

I received this answer back from AWS support, and it works:

As for the container, every beanstalk instance, is a container with beanstalk software that will download your application upon startup, and modify system parameters depending on the environment type, and on your .ebextensions folder on your application.

So in order to achieve my suggestion, you will need to create a .ebextensions on your application, with the contents I have mentioned.

Just as a recap, please create a file named app.config inside your .ebextensions folder on your application, with the following (updated) content:

files:
 "/etc/security/limits.conf":
     mode: "00644"
     owner: "root"
     group: "root"
     content: |
         *                soft    nofile          20000
         *                hard    nofile          20000

commands:
 container_commands:
      command: "ulimit -HSn 20000; service httpd restart;"

After you added this file, save the project and make a new deployment.

As for ssh, if you want to run a user with more limits, you can run the following command after you are logged in: sudo su -c "ulimit -HSn 20000; su - ec2-user"

And that current session will have the limits you so desire.

For reference: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-services https://unix.stackexchange.com/questions/29577/ulimit-difference-between-hard-and-soft-limits http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top