# Maximum number of file descriptors

**URL:** <https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715>\
**Category:** NGINX\
**Created:** [September 29, 2010, 12:07am UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715 "2010-09-29T00:07:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablo\_platt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d6d6ee/32.png) [@pablo\_platt](https://www.ruby-forum.com/u/pablo_platt)\
**Post date:** [September 29, 2010, 12:07am UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715/1 "2010-09-29T00:07:23Z")

</div>

Hi

I’m using nginx for long polling requests.  
Each user will have at least one hanging request in addition to  
requesting  
static files when needed.  
I understand that each connection needs a file descriptor.  
The default limit on ubuntu is 1024.  
How can I increase this limit?  
Do I need to change something on ubuntu or just in nginx config?  
Does worker\_rlimit\_nofile what I’m looking for or does it only set the  
limit  
per worker and I’ll still hit the master process limit?  
[http://wiki.nginx.org/NginxHttpMainModule#worker\_rlimit\_nofile](http://wiki.nginx.org/NginxHttpMainModule#worker_rlimit_nofile)

Thanks

---

<div class="post-metadata">

**Author:** ![pablo\_platt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d6d6ee/32.png) [@pablo\_platt](https://www.ruby-forum.com/u/pablo_platt)\
**Post date:** [September 29, 2010, 12:24am UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715/2 "2010-09-29T00:24:21Z")

</div>

Hi

On Tue, Sep 28, 2010 at 23:06, pablo platt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> The default limit on ubuntu is 1024.  
> How can I increase this limit?

That’s not nginx-specific, maybe you wanna ask in the ubuntu forums  
(or, better, Debian)?  
Or, better yet, try a search engine first:

> **[LMGTFY](https://lmgtfy.com/?q=linux+webserver+maximum+file+descriptor)**
>
> Let Me Google That For You (LMGTFY): for all those people who find it more convenient to bother you with their question rather than search it for themselves.

HTH,  
Nuno

---

<div class="post-metadata">

**Author:** ![pablo\_platt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d6d6ee/32.png) [@pablo\_platt](https://www.ruby-forum.com/u/pablo_platt)\
**Post date:** [September 29, 2010, 1:36am UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715/3 "2010-09-29T01:36:23Z")

</div>

2010/9/29 Nuno MagalhÃ£es [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> 

If you’ll read my question you’ll see that it is related to nginx.  
lmgtfy was funny years ago. The fact that you are still using it is a  
bit  
sad.

If someone else can answer my question I’ll appreciate it.

---

<div class="post-metadata">

**Author:** ![pablo\_platt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d6d6ee/32.png) [@pablo\_platt](https://www.ruby-forum.com/u/pablo_platt)\
**Post date:** [September 29, 2010, 1:36am UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715/4 "2010-09-29T01:36:58Z")

</div>

Hi,

> > The default limit on ubuntu is 1024.  
> > How can I increase this limit?
> 
> That’s not nginx-specific, maybe you wanna ask in the ubuntu forums  
> (or, better, Debian)?

Actually, it is:  
worker\_rlimit\_nofile XXXX;

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![pablo\_platt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d6d6ee/32.png) [@pablo\_platt](https://www.ruby-forum.com/u/pablo_platt)\
**Post date:** [September 29, 2010, 1:41am UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715/5 "2010-09-29T01:41:39Z")

</div>

Hi,

> Igor said that worker\_rlimit\_nofile is not enough:  
> [How to get nginx to see higher limit for file descriptors?](http://nginx.org/pipermail/nginx/2008-April/004596.html)

It works for me just fine.

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![pablo\_platt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d6d6ee/32.png) [@pablo\_platt](https://www.ruby-forum.com/u/pablo_platt)\
**Post date:** [September 29, 2010, 2:23am UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715/6 "2010-09-29T02:23:12Z")

</div>

On Wed, Sep 29, 2010 at 00:27, Piotr S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi,
> 
> > > The default limit on ubuntu is 1024.  
> > > How can I increase this limit?
> > 
> > That’s not nginx-specific, maybe you wanna ask in the ubuntu forums  
> > (or, better, Debian)?
> 
> Actually, it is:  
> worker\_rlimit\_nofile XXXX;

If you set worker\_rlimit\_nofile XXXX to 2048 you’re still gonna hit  
that 1024 system limit (assuming Ubuntu) and this directive is only  
for worker processes, not the master process (according to a link the  
OP provided, quoting Igor).

The first link on the search i provided points to how to increase the  
system limit for specific users (like www and similar, used by the OS  
to run the httpd).

Regards,  
Nuno

---

<div class="post-metadata">

**Author:** ![pablo\_platt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d6d6ee/32.png) [@pablo\_platt](https://www.ruby-forum.com/u/pablo_platt)\
**Post date:** [September 29, 2010, 1:39am UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715/7 "2010-09-29T01:39:18Z")

</div>

On Wed, Sep 29, 2010 at 1:27 AM, Piotr S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Actually, it is:  
> worker\_rlimit\_nofile XXXX;
> 
> Best regards,  
> Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

Igor said that worker\_rlimit\_nofile is not enough:

> **[How to get nginx to see higher limit for file descriptors?](http://mailman.nginx.org/pipermail/nginx/2008-April/004596.html)**

---

<div class="post-metadata">

**Author:** ![pablo\_platt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d6d6ee/32.png) [@pablo\_platt](https://www.ruby-forum.com/u/pablo_platt)\
**Post date:** [October 3, 2010, 4:20pm UTC](https://www.ruby-forum.com/t/maximum-number-of-file-descriptors/195715/8 "2010-10-03T16:20:36Z")

</div>

On Sep 29, Piotr S. wrote:

> > Igor said that worker\_rlimit\_nofile is not enough:  
> > [How to get nginx to see higher limit for file descriptors?](http://nginx.org/pipermail/nginx/2008-April/004596.html)
> 
> It works for me just fine.

It works as long as your master process is running as root. Given that  
nginx is usually listening on port 80, the master process is usually  
running as root.

My pratical observation is that the limits seem to be set before the  
workers are forked and hence, the elevated limits seem to be carried  
forward.

limits.conf is applicable for user-sessions. A program started directly  
by init is unaffected by these settings.

Note that all the statements above are for linux. I am not sure how it  
works on FreeBSD.
