Why is 'multi_accept' 'off' as default in Nginx?

I found 'multi_accept' is 'off' as default in Nginx as follows:

multi_accept


Probably because with on, all the worker processes are active and try to handle all of the incoming request simultaneously. When disabled, Nginx decides which child process gets to deal with the request one by one. As Nginx is very efficient at this, this probably serves most people well. Some consider it a risk to enable it, as it may flood the worker connections with requests. Your TCP settings at OS level will likely play a part in this too.


multi_accept off: a worker accepts just a single connection, handles it and then returns to the kernel for the next event to process.

multi_accept on: a worker would do accept in a loop until it gets EAGAIN finally. This might be beneficial if there're quite a lot of connections by cutting off events handling which requires an additional kernel involvement. But if there're not that many incoming connections then EAGAIN would be hit pretty often, say with 1:1 ratio. This approach could also inflict a connection handling misbalance specially when they arrive irregularly and SO_REUSEPORT isn't in use.

All in all — it's kinda "hacky", probably not worth tinkering with it at all, but the knob is still there — just in case it could be helpful.

Heavily based on explanation by Valentin Bartenev, nginx-ru mailing list.