Client body buffering with FastCGI

Maxim Dounin mdounin at mdounin.ru
Sat Feb 19 01:40:00 MSK 2011


Hello!

On Fri, Feb 18, 2011 at 03:17:25PM -0500, Maxim Khitrov wrote:

> On Fri, Feb 18, 2011 at 10:28 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> > Hello!
> >
> > On Fri, Feb 18, 2011 at 07:43:09AM -0500, Maxim Khitrov wrote:
> >
> > [...]
> >
> >> Here's the information in case you want to see why unix sockets cause
> >> this problem. I don't think you even need to use the specific software
> >> I was trying to configure. Write a 1-line PHP script that saves some
> >> POSTed variable to a file. Then post more than 64 MB of data and see
> >> if it breaks.
> >>
> >> The OS is FreeBSD 7.3-RELEASE-p4 amd64. Nginx 0.8.54 configuration for
> >> AjaXplorer with irrelevant parts removed:
> >
> > [...]
> >
> >>     sendfile on;
> >
> > [...]
> >
> >>             fastcgi_pass unix:/tmp/php.sock;
> >
> > [...]
> >
> > Ok, thanks for info.  I tend to think that it's kernel problem
> > with sendfile(2) and unix sockets.
> >
> > Could you please test if a) not using sendfile (in location in
> > question) resolves the problem and b) not using unix sockets
> > resolves the problem?  Just to make things more clear.
> >
> > I'll try to reproduce this issue here and dig further into it, but
> > unfortunately I'm a bit busy now and it's unlikely to happen
> > anytime soon.
> >
> > Maxim Dounin
> 
> Interesting - both a and b solve the problem. I didn't think that
> sendfile would be used to transfer the request to the FastCGI socket,
> but I guess that's where the problem is.

Ok, thanks for testing.

> Which configuration provides more efficient data transfer - sendfile
> on with a TCP socket, or sendfile off with a unix socket?

The speed difference between tcp and unix sockets isn't that huge, 
and copyin/copyout overhead without sendfile is likely to be 
bigger.  Though a) I've never tested and b) disk seeks may be more 
important if you in fact hitting disk.

Maxim Dounin



More information about the nginx mailing list