TransWikia.com

How can I troubleshoot slow Apache?

Server Fault Asked on November 18, 2021

I am running apache2 (2.2) on Ubuntu on a VPS with 768MB of RAM. For some reason it takes several seconds to load any page (even static html). The only component I can blame is Apache. However, I have no idea why it is acting that way. I even installed NewRelic to see if maybe it would help me diagnose the problem in a more visual and friendly format. I see that apache2 is using about 400MB of RAM, which seems like a lot, but the total is still well under 100%. I am still confused as to what the real problem is or how to properly diagnose it.

Memory usage according to top (as asked by answerer):

Mem:    768848k total,   753380k used,    15468k free,    39792k buffers
Swap:   262140k total,    92696k used,   169444k free,   432888k cached

Results for “free -m”:

             total       used       free     shared    buffers     cached
Mem:           750        733         17          0         35        414
-/+ buffers/cache:        282        467
Swap:          255         90        165

2 Answers

  1. Install mod_status and grant access to the URL /server_status for your IP - so you can see what Apache is exactly doing - maybe someone is hammering your server with requests
  2. Look at pstree to make sure that the total count of apache processes is below 250 - 250 is a magic limit
  3. Review error.log and access.log
  4. Use top and type 'C' or 'M' to have a detailed insight on what your system is doing

Answered by DanielKhan on November 18, 2021

probably your apache is causing swapping - look on the top how much memory does it use.

if you serve just static content - skip diagnosing problems with apache all together and replace it with nginx, mathopd or lighttpd. they'll give you much better performance at smaller memory footprint.

if you serve both static and dynamic content - you can still run apache at other ip or other port and use nginx as reverse proxy to the dynamic parts while serving static assets directly from nginx.

Answered by pQd on November 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP