Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache requests very slow after using ProxyPass

So I'm running Tomcat(8.0) behind Apache(2.4) on Windows Server 2012 and using ProxyPass to pass through all traffic. Everything works fine, but whenever I do nothing for 60 seconds, and then hit the server again, i get a 8-20 second delay, like apache is creating a new process to handle the request.

My configuration is pretty much the default that comes with Apache Haus, with the addition of the proxy stuff, which I believe is the culprit:

ProxyPass         /static/ !
ProxyPass         /  http://localhost:8088/
ProxyPassReverse  /  http://localhost:8088/

I added the

/static/ !

exemption to see if same problem would happen on static files being served, and apparently it does. I further narrowed it down by commenting out all the ProxyPass stuff, and verifying my static file always loads fast. Then i uncommented ProxyPass stuff, and only requested my static file, and it again always returned fast. But once I hit a URL that takes me through the proxy, wait a minute, then hit it again, something goes horribly wrong. Below is network monitor output for two requests, first of the static file being requested a second time after a 1 minute delay before proxy use, the other after the proxy had been used twice with delay between proxy requests.

3501   4:17:48 PM 10/21/2015   104.2752287   httpd.exe   HTTP   HTTP:Request, GET /static/index.html 
3502   4:17:48 PM 10/21/2015   104.2760830   httpd.exe   HTTP   HTTP:Response, HTTP/1.1, Status: Not modified, URL: /static/index.html 

After (8 seconds to return):

24232   4:26:13 PM 10/21/2015   608.7355960   httpd.exe   HTTP   HTTP:Request, GET /static/index.html 
24775   4:26:20 PM 10/21/2015   616.0896861   httpd.exe   HTTP   HTTP:Response, HTTP/1.1, Status: Not modified, URL: /static/index.html 

I'm noticing more of this SynReTransmit line after it was initially broken, not sure if it's relevant:

24226   4:26:13 PM 10/21/2015   608.7286692   httpd.exe   TCP   TCP:[SynReTransmit #24107]Flags=......S., SrcPort=61726, DstPort=HTTP(80), PayloadLen=0, Seq=1157444168, Ack=0, Win=8192 ( Negotiating scale factor 0x2 ) = 8192

But basically every call, be it to static file or over proxy, if it's been over 60 seconds since the last call, will take forever to get a response!

Any ideas?

UPDATE: I was running a slightly older version of Apache, 2.4.12, but updating to latest, 2.4.17, didn't fix it. I've tried all sorts of keepalive settings, nothing seems to help. On another forum i was directed at this apache dev thread which has a proposed patch for what sounds like a similar issue, guess I'll wait for an apache update:

http://marc.info/?l=apache-httpd-dev&m=144543644225945&w=2

like image 712
Klaus Avatar asked Oct 22 '15 15:10

Klaus


People also ask

What is ProxyPass in Apache?

ProxyPass is the main proxy configuration directive. In this case, it specifies that everything under the root URL ( / ) should be mapped to the backend server at the given address.

What is the use of ProxyPass?

ProxyPassReverse will intercept those headers, and rewrite them to match the Apache proxy server. ProxyPass will create a reverse proxy. A reverse proxy (or gateway), appears to the client just like an ordinary web server. The client makes ordinary requests for content in the namespace of the reverse proxy.

What is proxy timeout in Apache?

Apache has a default timeout of 60 seconds, you can increase it by creating a custom template in cwp.

What is Apache ProxyPreserveHost?

The ProxyPreserveHost directive is used to instruct Apache mod_proxy, when acting as a reverse proxy, to preserve and retain the original Host: header from the client browser when constructing the proxied request to send to the target server.


1 Answers

Try explicitly tuning the ProxyReceiveBufferSize:

# For increase throughput (bytes)
ProxyReceiveBufferSize 2048
like image 93
Brice Roncace Avatar answered Sep 22 '22 16:09

Brice Roncace