# How do I look for the reasons for a very slow webserver

## Letharion

I have a VM with Apache server placed outside of the network. Sometimes, it just grinds to a halt, and loading a webpage takes anywhere in the range 5-60 seconds.

I don't know where to start looking.

It could be apache, ssl, the network, a firewall, hardware, and most likely a long line of other things.

After googling, I found the suggestion to put httpd.conf on a modules diet, which I did, but the problem remains. This was done in a dumb brute force fashion y by removing most modules, and then starting to add modules back until the server worked as expected. At the time, this felt like the solution, as the loadtime felt significantly shorter, but this morning, the problem is back.

Any suggestions on where I start?

Here is a list of the un-commented modules.

```
LoadModule python_module modules/mod_python.so

LoadModule authn_file_module modules/mod_authn_file.so

LoadModule authz_host_module modules/mod_authz_host.so

LoadModule dir_module modules/mod_dir.so

LoadModule env_module modules/mod_env.so

LoadModule rewrite_module modules/mod_rewrite.so

LoadModule mime_module modules/mod_mime.so

<IfDefine CACHE>

LoadModule cache_module modules/mod_cache.so

</IfDefine>

<IfDefine DAV>

LoadModule dav_module modules/mod_dav.so

LoadModule dav_fs_module modules/mod_dav_fs.so

LoadModule dav_lock_module modules/mod_dav_lock.so

LoadModule dav_svn_module modules/mod_dav_svn.so

</IfDefine>

<IfDefine CACHE>

LoadModule disk_cache_module modules/mod_disk_cache.so

</IfDefine>

<IfDefine CACHE>

LoadModule file_cache_module modules/mod_file_cache.so

</IfDefine>

<IfDefine INFO>

LoadModule info_module modules/mod_info.so

</IfDefine>

<IfDefine CACHE>

LoadModule mem_cache_module modules/mod_mem_cache.so

</IfDefine>

<IfDefine SSL>

LoadModule ssl_module modules/mod_ssl.so

</IfDefine>

<IfDefine STATUS>

LoadModule status_module modules/mod_status.so

</IfDefine>

<IfDefine USERDIR>

LoadModule userdir_module modules/mod_userdir.so

</IfDefine>
```

----------

## vincent-

Any possibility to try into the same local network as the server?

----------

## Letharion

You mean transfer the VM?

Or do you mean just trying to install apache locally and see what happens?

If the former, then I guess I could try, but I'm not sure about the details of running the VM. I think it's using vSphere, which would require a computer to install that first, and that might take a lot of time. But could also be very fast, I don't know

----------

## vincent-

I mean connect to the server using a PC on the same local network (connected to the same router), to discard that Internet conection is slow between the clients and your server.

----------

## Letharion

 *peratu wrote:*   

> I mean connect to the server using a PC on the same local network (connected to the same router), to discard that Internet conection is slow between the clients and your server.

 

I realised that just recently too, that there's a much easier way of getting to the local network. Why bring the mountain to me when I can go there?  :Wink: 

I will head over to the local net and see what happens.

----------

## clouds222

Letharion

Have you enabled MPM? this enable your server to creat multi-threads to process the http requests.

you can add mpm support to your apache server by:

```

USE="threads apache2_mpms_worker" emerge --newuses apache php

```

also you can use " apache2_mpms_prefork" or  "apache2_mpms_event"

and then, configure your mpm configuration files located at: /etc/apache2/modules.d/00_mpm.conf

```

<IfModule mpm_worker_module>

        StartServers            2

        MinSpareThreads         25

        MaxSpareThreads         75

        ThreadsPerChild         25

        MaxClients                      150

        MaxRequestsPerChild     10000

</IfModule>

```

though this will do better to your server.

other ways to make your server faster is to enable compress output. You can look at the other posts of the forum.

----------

## cach0rr0

two cents - I recommend prefork

I'm posting from the crapper, so not convenient to go into detail as to why

----------

## clouds222

Well, you can choose which module to use by actual application. And you may need to read the difference between each other from the documents:

http://www.apache2.es/2.2.2.en/mpm.html

 *Quote:*   

> The server can be better customized for the needs of the particular site. For example, sites that need a great deal of scalability can choose to use a threaded MPM like worker or event, while sites requiring stability or compatibility with older software can use a prefork. 
> 
> 

 

----------

## Letharion

Thanks, I've read on the different mpms, and it looks like I can basically choose from worker or prefork.

I'm currently using prefork, so maybe I'll try the worker. I talked to the admin of the network on the other end, and he said he'd seem the problem before, so maybe it's there. Will investigare further  :Smile: 

----------

## lesourbe

I'll try to investigate with these tools first :

fireplug

wireshark

and try to trigger the issue.

----------

## Letharion

I'm currently on the local network, logged in with putty, and browsing a trac-site. It's a bit faster, but still really, really slow.

fire"plug"?

If you mean firebug, that sounds like a good idea. Never heard of a plug, nor does google reveal anything intersting.

Wireshark also sounds interesting, but I fear that I might get more information than I'm able to interpret.

----------

## lesourbe

 *Letharion wrote:*   

> I'm currently on the local network, logged in with putty, and browsing a trac-site. It's a bit faster, but still really, really slow.
> 
> fire"plug"?
> 
> If you mean firebug, that sounds like a good idea. Never heard of a plug, nor does google reveal anything intersting.
> ...

 

indeed I mistyped firebug.

Wireshark allow live capture and filtering, it helps analysis.

----------

## Letharion

Host thinks there's an issue with the VM-server, it will be reinstalled. Will await results of this.

----------

## Letharion

Ok, long long overdue.

A faulty switch had been replaced on the host side, however, my problem remained.

After playing around a bit with the kernel looking for configuration mistakes, Trac got an "Internal Error". I don't know what I did to cause this, but quickly found a fix on google that I applied to httpd.conf.

After that Trac isn't that slow anymore. Otherwise, the server doesn't feel much faster, but Trac loads in less than a tenth of what it used to.

----------

