httpd max connections ?

Denys Vlasenko vda.linux at googlemail.com
Tue Jan 8 13:45:16 UTC 2008


On Tuesday 08 January 2008 13:28, Mark Jackson wrote:
> I'm running bb v1.7.2 and I use the built-in httpd.
> 
> Can I limit the number of connections / requests allowed by httpd ?
> 
> Or can someone suggest a method of preventing / limiting a "too many 
> requests at the same time" type situation ?

One good option is to limit connections by iptables -
might be the least expensive solution.

On application level, use tcpsvd -c NUM and/or
tcpsvd -C NUM   +   httpd in inetd mode:

tcpsvd -c <num> ..opts.. <ip> <port> httpd -i ..opts..

More info:

$ ./busybox tcpsvd --help
BusyBox v1.10.0.svn (2008-01-07 16:43:01 GMT) multi-call binary

Usage: tcpsvd [-hEv] [-c n] [-C n:msg] [-b n] [-u user] [-l name] ip port prog...

Creates TCP socket, binds it to ip:port and listens on it
for incoming connections. For each connection it runs prog.

ip              IP to listen on. '0' = all
port            Port to listen on
prog [arg]      Program to run
-l name         Local hostname (else looks up local hostname in DNS)
-u user[:group] Change to user/group after bind
-c n            Handle up to n connections simultaneously
-b n            Allow a backlog of approximately n TCP SYNs
-C n[:msg]      Allow only up to n connections from the same IP
                New connections from this IP address are closed
                immediately. 'msg' is written to the peer before close
-h              Look up peer's hostname
-E              Do not set up environment variables
-v              Verbose

$ ./busybox httpd --help
BusyBox v1.10.0.svn (2008-01-07 16:43:01 GMT) multi-call binary

Usage: httpd [-c conffile] [-p [ip:]port] [-i] [-f] [-v[v]] [-u user[:grp]] [-r realm] [-m pass] [-h home] [-d/-e string]

Listen for incoming HTTP requests

Options:
        -c FILE         Configuration file (default httpd.conf)
        -p [IP:]PORT    Bind to ip:port (default *:80)
        -i              Inetd mode
        -f              Do not daemonize
        -v[v]           Verbose
        -u USER[:GRP]   Set uid/gid after binding to port
        -r REALM        Authentication Realm for Basic Authentication
        -m PASS         Crypt PASS with md5 algorithm
        -h HOME         Home directory (default .)
        -e STRING       HTML encode STRING
        -d STRING       URL decode STRING


--
vda



More information about the busybox mailing list