0

We are facing a Strange Problem....We have a busy server...and the response time is going about 1 Minute Per Request(very slow).....which is running in front of Tomcat.....if we are accessing site with xyz.com:8080 Its super fast(1 Req/Sec).....and we are using Mod_Proxy which redirect the request to tomcat.....My question instead of passing the request from apache to tomcat can we directly send request to tomcat...or do we need to some config in Apache.......

Here is the Httpd.conf file looks like..

ProxyPreserveHost On 
ProxyPass / http://localhost:8080/ retry=1 acquire=300 timeout=60 Keepalive=On 
ProxyPassReverse / http://localhost:8080/ ErrorLog /Path/To/Logs/Apache.log LogLevel warn
user9517
  • 115,471
  • 20
  • 215
  • 297
gopal gupta
  • 1
  • 1
  • 1

1 Answers1

1

I presume your Apache is running fast, but just slow for the Tomcat requests? Question not entirely clear and if your Apache itself is slow then you need to look at that. Only one process can listen on port 80 so if you don't want to specify the port than you are going to have to go through Apache. Or scrap Apache completely and get tomcat to listen on port 80 instead. However Apache should be fast enough to proxy this.

Few things I can suggest if Apache itself is fast but just slow for the proxied Tomcat requests:

It could be a slow DNS lookup but that's rare on localhost. I presume localhost is in the hosts file? Could you change this to 127.0.0.1 so you don't need a DNS lookup?

Do you need all those options?

  • ProxyPreserveHost - does Tomcat need to know about the host name? If not any need to preserve it?
  • retry/aquire/timeout/keepalive - they're more meant for when the proxy is not on a reliable connection or behind a firewall. They shouldn't be needed when Apache and Tomcat sit on the same server.
  • Custom log files for proxy requests can be useful but not used them myself.

Can't see why they would cause issues but haven't used them so first suggestion would be to rip them out and see if that improves things. Then, if you need them, add them back in one by one to see where the issue was.

So I would simplify and replace with this:

ProxyPass / http://127.0.0.1:8080/ 
ProxyPassReverse / http://127.0.0:8080/

And then try again.

I also presume you're loading mod_proxy? Sometimes the simplest things can be missed out ;-)

Barry Pollard
  • 4,591
  • 15
  • 26
  • Ran into a similar issue with an ec2 instance. Turns out in a block, I had 'Allow from localhost'. Doing this answer, as well as changing it to 'Allow from 127.0.0.1' fixed the issue. – Danedo Aug 13 '17 at 19:32
  • I realize this is an old question but just ran into this today. Just changing ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ to ProxyPass / http://127.0.0.1:8080/ ProxyPassReverse / http://127.0.0.1:8080/ sped things up a lot! – Dunfield Nov 08 '22 at 18:10