My setup:
- nginx is listening on port 80 and working as a reverse proxy (plus directly sending static files)
- Apache 2 is listening on port 8080
- PHP is running in Apache 2
- All running on one server (no internal network latency)
My problem:
Static files now are very fast, but everything going through the proxy takes a lot of extra time.
One example is a "search-as-you-type" tag suggestion box. When I connect to Apache directly though port 8080 everything is fine and the server responds quickly (~50 ms). When I use the "normal path" through port 80 (nginx -> Apache) every request takes about 15 times as long (~750 ms).
I expected some more time. Right now requests are not leaving the server in any way, so why do they take so much more time to process? How do I make them faster?
Is there any way I can use persistent connections between nginx and Apache?
Is there any way to benchmark where exactly that additional 0.7 second is added?
Main interest: Can I find out if this time comes from internal processing in nginx (e.g. hostname table lookup) or is it the connection to Apache. Is nginx waiting for an open socket - or what happens here?
Okay, I finally found my problem - and it looks as if I was causing my own problems:
I misconfigured limit_req_zone throttling my server down to a crawl slower than expected.