I have a stock lighttpd install on a Amazon Linux AMI running on EC2. The only config changes I did is to enable CGI support.
Then there is a custom CGI tool (written in C) put in /cgi-bin/ that is called from the outside world and outputs gzip'ed JSON. This tool outputs data regularly, say every 10-20 seconds, but only a few hundreds bytes each time.
The problem is that somewhere between the CGI stdout and what lighttpd returns to the client, things are buffered and arrive about 4KB at a time. Unfortunately, this system is behind the Amazon Elastic Load Balancer which doesn't allow idle connections for more than 60 seconds. Because of the buffering, it's as-if the server returns nothing the first 60 seconds, so the connection gets killed and the client doesn't get anything.
So how do I track down this buffering setting and reduce it significantly? I tried changing some lighttpd config parameters and even changing "net.ipv4.tcp_wmem" in the kernel, but nothing appears to work.