Nginx response time doubles after exceeding 14k ??

Operating System & Version
CentOS 7.9.2009
cPanel & WHM Version
v100.0.5
Dec 26, 2021
6
2
3
Vancouver
cPanel Access Level
Root Administrator
Hello everyone!

I'm having this weird situation that I can't seem to pinpoint but maybe you could.

I'm using Nginx as a proxy and cache upstreaming to Apache and PHP.
and when I make a request to a file (both dynamic or static), the response takes about 60ms to generate IF the response is smaller than 14kb. If the resulting response is greater than 14kb, the response time from Nginx almost doubles (~115ms).
I looked at all my directives and tried to change everything but with no luck.

It's almost that if the response is less than a certain byte length, it passes it directly to the client, whereas if it's greater than that, it writes it to a file first, but I can't find what controls this. Generally I would like to raise that threshold....

Would you know how to solve this challenge? :)

-Sergey
 
  • Like
Reactions: cPanelAnthony

gnusys

Well-Known Member
Jan 18, 2013
61
19
58
cPanel Access Level
DataCenter Provider
  • Like
Reactions: gizmifystudios
Dec 26, 2021
6
2
3
Vancouver
cPanel Access Level
Root Administrator
The directives you should be looking at is the ones that follow Module ngx_http_proxy_module

You can also adjust the cache path and serve it directly from memory -- Cache Placement Strategies for NGINX and NGINX Plus

You can turn off proxy_buffering in entire, but then it disabled proxy caching too..so adjusting is the possible way around
Yup, the directives you mentioned are what I thought needs to be changed, but I'm seeing no difference playing around with them for some reason.
The drop in performance still happens at around 14kb of response size even if I change the proxy_buffers and proxy_busy_buffers_size directives to a higher size.

I don't think I want to play around with the tmpfs solution as my server memory is limited and using the ssd for caching is much more scalable in my case.

Is there anything else I could look into? Could I have missed somethingout of what you specified?
 

gnusys

Well-Known Member
Jan 18, 2013
61
19
58
cPanel Access Level
DataCenter Provider
Are you sure the config is reloaded? To be completely sure, please do a restart of the Nginx service

Also, tail the Nginx log for any relevant info's

I have not personally seen such a behavior in Nginx , but the config I use may be different than your's

You can also post in the Nginx community mailing list ( [email protected] ). It is very active and you may get much better response there