denji / nginx-tuning

NGINX tuning for best performance
https://git.io/vSvsq
MIT License
2.46k stars 384 forks source link

Mixing sendfile, tcp_nodelay and tcp_nopush illogical? #5

Closed rokcarl closed 4 years ago

rokcarl commented 5 years ago

The following article suggests that mixing sendfile, tcp_nodelay and tcp_nopush makes no sense.

I'd love to hear your thoughts on this and can really many of the resources be wrong about it?

saamalik commented 4 years ago

Hi @rokcarl - I think it's advocating for all three flags simultaneously.

When set indicates to always queue non-full frames. Later the user clears this option and we transmit any pending partial frames in the queue. This is meant to be used alongside sendfile() to get properly filled frames when the user (for example) must write out headers with a write() call first and then use sendfile to send out the data parts. TCP_CORK can be set together with TCP_NODELAY and it is stronger than TCP_NODELAY.

rokcarl commented 4 years ago

I read the article differently.

Either way, I'm not convinced by the article, especially after reading Nginx High Performance . For my use-case as a reverse proxy, just setting tcp_nodelay worked fine and the other two switches yielded no improvements, as expected.