lighttpd forum lighty > server.max-fds & number of file descriptors

Posted by Alexander (Guest)
on 17.04.2006 17:30
Hello
As I can see in documentation 
http://lighttpd.net/documentation/performance.html#max-connections
server.max-fds option will only works if lighttpd is started as root.

But I'm run lighttpd as 'www-data' user.

Is there any way how I can increase the number of file descriptors, 
which lighttpd can use?
Posted by Michael F.
on 18.04.2006 11:25
Alexander wrote:
> Hello
> As I can see in documentation 
> http://lighttpd.net/documentation/performance.html#max-connections
> server.max-fds option will only works if lighttpd is started as root.
> 
> But I'm run lighttpd as 'www-data' user.
> 
> Is there any way how I can increase the number of file descriptors, 
> which lighttpd can use?

I believe you can do that by going to /etc/limits and following the 
format to write those in. It'll allow you to set the amount of file 
descriptors. try looking it up google, I can't remember exactly which 
files to edit but there's a global file descriptors limit in /etc/sysctl 
as well.
Posted by Alexander (Guest)
on 18.04.2006 13:50
Michael Fuita wrote:

> I believe you can do that by going to /etc/limits and following the 
> format to write those in. It'll allow you to set the amount of file 
> descriptors. try looking it up google, I can't remember exactly which 
> files to edit but there's a global file descriptors limit in /etc/sysctl 
> as well.

I've added these lines to /etc/security/limits.conf:
www-data        soft    nofile          4096
www-data        hard    nofile          63536

And to /etc/sysctl.conf:
fs.file-max = 100000

Now when I'm doing
#su - www-data
and
$ulimit -n
I get 4096.

But all the same. Lighttpd crashes every time when it reaches more than 
1k connection.

PS. I'm using Debian etch.
Posted by Michael F.
on 19.04.2006 01:17
Alexander wrote:
> 
> I've added these lines to /etc/security/limits.conf:
> www-data        soft    nofile          4096
> www-data        hard    nofile          63536
> 
> And to /etc/sysctl.conf:
> fs.file-max = 100000
> 
> Now when I'm doing
> #su - www-data
> and
> $ulimit -n
> I get 4096.
> 
> But all the same. Lighttpd crashes every time when it reaches more than 
> 1k connection.
> 
> PS. I'm using Debian etch.

Do ulimit on your server and tell me if it tells you it's unlimited or
not.
Posted by Alexander (Guest)
on 19.04.2006 10:31
Michael Fuita wrote:

> Do ulimit on your server and tell me if it tells you it's unlimited or
> not.

It tells "unlimited".
Posted by Michael F.
on 19.04.2006 23:23
Alexander wrote:
> Michael Fuita wrote:
> 
>> Do ulimit on your server and tell me if it tells you it's unlimited or
>> not.
> 
> It tells "unlimited".

It should work, just remember to change the server.max-fds = to 4096 in 
lighttpd.conf. I did exactly the same thing for file descriptors for 
mysql and it works.

You may want to have a look at how they did it, similar but there is the 
nproc step that you may have missed.

http://forums.mysql.com/read.php?24,39066,44839#msg-44839
Posted by Jan Kneschke
on 20.04.2006 13:07
Alexander wrote:
> Hello
> As I can see in documentation 
> http://lighttpd.net/documentation/performance.html#max-connections
> server.max-fds option will only works if lighttpd is started as root.
> 
> But I'm run lighttpd as 'www-data' user.
> 
> Is there any way how I can increase the number of file descriptors, 
> which lighttpd can use?

There is difference between 'starting' and 'running'. Usually you start 
as root as you want to bind to port 80, 443, read certificates, ... and 
switch to 'www-data' afterwards.

Setting max-fds falls into the same group of setting that are only 
changable for root.

So, just set it and set server.username = "www-data" and everything will 
work as expected.

Jan