Klaus
Klaus

Reputation: 93

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

Upvotes: 7

Views: 13122

Answers (3)

kkid
kkid

Reputation: 81

I was using Apache httpd as reverse proxy and it was drastically slow (2 mins to load a single web page). But, as soon as changed the hostname to IP address it was super fast.

before: ProxyPass "/home" "http://hostname.domain.com:port/home"

After: ProxyPass "/home" "http://ip:port/home"

Hope it helps someone.

Upvotes: 2

phongnt
phongnt

Reputation: 781

In httpd config, add these follow lines:

AcceptFilter http none 
AcceptFilter https none 
EnableSendfile Off 
EnableMMAP off

right after this line:

Listen 80

My response get less than 2 time but it still quite slow than normal.

From https://www.apachelounge.com/viewtopic.php?p=26601

Upvotes: 1

Brice Roncace
Brice Roncace

Reputation: 10670

Try explicitly tuning the ProxyReceiveBufferSize:

# For increase throughput (bytes)
ProxyReceiveBufferSize 2048

Upvotes: 5

Related Questions