Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a problem with my server (VPS). It's veeery slow.

Checking the connections with netstat, there are a lot of internal connections. I don't understand why!

It's normal all this connections?

# netstat -anp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp      174      0 localhost:80        localhost:50035     ESTABLISHED -               
tcp        0      0 localhost:80        localhost:49523     FIN_WAIT2   -               
tcp      174      0 localhost:80        localhost:50034     ESTABLISHED -               
tcp        0      0 localhost:80        localhost:49522     FIN_WAIT2   -               
tcp      174      0 localhost:80        localhost:50045     ESTABLISHED -               
tcp      174      0 localhost:80        localhost:50044     ESTABLISHED -               
tcp      174      0 localhost:80        localhost:50043     ESTABLISHED -               
tcp        0      0 localhost:80        localhost:49531     FIN_WAIT2   -               
tcp      174      0 localhost:80        localhost:50042     ESTABLISHED -               
tcp    14494      0 localhost:49448     localhost:80        CLOSE_WAIT  24351/apache2   
tcp    14556      0 localhost:49449     localhost:80        CLOSE_WAIT  24351/apache2   
tcp    25098      0 localhost:49450     localhost:80        CLOSE_WAIT  24351/apache2   
tcp    26914      0 localhost:49444     localhost:80        CLOSE_WAIT  24351/apache2   
tcp    21143      0 localhost:49445     localhost:80        CLOSE_WAIT  24351/apache2   
tcp    17907      0 localhost:49446     localhost:80        CLOSE_WAIT  24351/apache2   
tcp    22300      0 localhost:49519     localhost:80        CLOSE_WAIT  -               
tcp    25098      0 localhost:49528     localhost:80        CLOSE_WAIT  -               
tcp      861      0 localhost:49531     localhost:80        CLOSE_WAIT  24170/apache2   
tcp    17907      0 localhost:49524     localhost:80        CLOSE_WAIT  -               
tcp    16336      0 localhost:49525     localhost:80        CLOSE_WAIT  -               
tcp    14494      0 localhost:49526     localhost:80        CLOSE_WAIT  -               
tcp    14556      0 localhost:49527     localhost:80        CLOSE_WAIT  -               
tcp    51238      0 localhost:49520     localhost:80        CLOSE_WAIT  -               
tcp    18377      0 localhost:49521     localhost:80        CLOSE_WAIT  -               
tcp        0      0 localhost:50003     localhost:80        ESTABLISHED 24417/apache2   
tcp        0      0 localhost:49839     localhost:80        ESTABLISHED -               
tcp      780      0 localhost:49838     localhost:80        ESTABLISHED -               
tcp     3348      0 localhost:49837     localhost:80        ESTABLISHED -               
tcp      925      0 localhost:49836     localhost:80        ESTABLISHED -               
tcp     4159      0 localhost:49835     localhost:80        ESTABLISHED -               
tcp     1960      0 localhost:49834     localhost:80        ESTABLISHED -               

This is only a resume, there are hundred of them.

How can I fix it?

Thanks a lot!

EDIT: Problem seems to be the high CPU use for apache proccess.

top - 09:59:17 up 20:06,  1 user,  load average: 49.51, 41.65, 33.52
Tasks:  73 total,  27 running,  46 sleeping,   0 stopped,   0 zombie
Cpu(s): 91.4%us,  8.6%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1048576k total,   732896k used,   315680k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 7978 www-data  16   0 93832  28m 6656 R 11.2  2.8   0:20.99 apache2
 8182 www-data  16   0 93812  27m 6768 R 11.2  2.7   0:07.19 apache2
 8163 www-data  16   0 90068  23m 5412 R 10.9  2.3   0:07.00 apache2
 8095 www-data  16   0 88584  23m 6544 S  3.8  2.3   0:19.31 apache2
 8097 www-data  15   0 88204  23m 6524 S  3.5  2.3   0:17.58 apache2
 8175 www-data  16   0 90780  23m 5900 S  3.5  2.3   0:07.40 apache2
 8058 www-data  15   0 84916  21m 8388 S  3.2  2.1   0:18.26 apache2
 8018 www-data  17   0 89460  23m 6388 R  2.9  2.3   0:15.99 apache2
 8112 www-data  16   0 89308  24m 7276 S  2.9  2.4   0:17.65 apache2
 7880 www-data  17   0 99532  34m 8364 R  2.6  3.3   0:26.61 apache2
 7885 www-data  17   0 94680  28m 7892 R  2.6  2.7   0:28.58 apache2
 7916 www-data  17   0 90388  24m 7932 R  2.6  2.4   0:35.33 apache2
 8002 www-data  17   0 95820  30m 7176 R  2.6  3.0   0:13.93 apache2
 8022 www-data  17   0 96336  31m 7728 R  2.6  3.1   0:21.56 apache2
 8035 www-data  17   0 88728  23m 7464 R  2.6  2.3   0:22.86 apache2
 8066 www-data  17   0 96124  29m 6676 R  2.6  2.9   0:19.17 apache2
 8070 www-data  17   0 93432  26m 6600 R  2.6  2.6   0:17.57 apache2
 8092 www-data  17   0 92668  26m 6260 R  2.6  2.6   0:20.82 apache2
 8142 www-data  17   0 96536  28m 7024 R  2.6  2.7   0:09.55 apache2
 8158 www-data  17   0 84420  18m 5480 S  2.6  1.8   0:06.44 apache2
 8161 www-data  16   0 88452  22m 5924 S  2.6  2.2   0:09.34 apache2
 8171 www-data  17   0 91236  25m 5648 R  2.6  2.4   0:05.09 apache2
 8088 www-data  17   0 88132  22m 6456 S  2.2  2.2   0:14.52 apache2
 8009 www-data  17   0 91484  26m 6468 S  1.9  2.5   0:17.19 apache2
 8116 www-data  16   0 91204  24m 7176 S  1.6  2.4   0:15.72 apache2
 8029 www-data  17   0 92784  26m 7708 S  1.3  2.6   0:23.54 apache2
 7964 www-data  17   0 86836  22m 7676 R  1.0  2.2   0:24.60 apache2
 8032 www-data  16   0 84836  20m 7564 S  1.0  2.0   0:17.05 apache2
 8084 www-data  17   0 99564  32m 6796 R  1.0  3.2   0:15.57 apache2
 8148 www-data  15   0 91424  26m 6356 S  1.0  2.5   0:08.83 apache2
 8062 www-data  17   0 88708  23m 7592 S  0.6  2.3   0:13.60 apache2
 8108 www-data  17   0 92492  25m 6832 S  0.6  2.5   0:18.80 apache2
 8153 www-data  17   0 82604  16m 5364 S  0.6  1.6   0:07.91 apache2
 8006 www-data  17   0 85296  20m 7052 S  0.3  2.0   0:18.04 apache2
 8014 www-data  17   0 88696  25m 8124 S  0.3  2.4   0:19.57 apache2
share|improve this question
1  
Any hints as to what software is running on there; or are we supposed to just guess? –  Chris S Aug 10 '11 at 16:58
1  
It could be normal, it completely depends on what you are doing. –  Zoredache Aug 10 '11 at 17:04
    
It's only a web server. Most of proccess are apache2, mysql or courier mail. But the server has open a lot of internal connections. –  Lito Aug 11 '11 at 7:48

2 Answers 2

up vote 1 down vote accepted

If you're running some resource-intensive process on a local web server, maybe these connections are the problem. But a high of connections isn't bad (and that number of connections isn't high), it's what a high number of connections causes.

If your machine is slow, look at load. Check top's output for high-CPU processes. See if all your memory is used up by php. In short, examine the whole machine.

You could run lsof -i as root and get a little more information about that web server and who's contacting it. But presumably you already know about it since (presumably) you set it up.

share|improve this answer

Either some PHP script is accessing your web server over http (perhaps using curl functions?), or you have ErrorDocument pages configured in wrong way in Apache configuration files or some .htaccess file.

Basically, if you configure ErrorDocuments in this way:

ErrorDocument 404 http://yourhost/someerrorpage.html

And that someerrorpage.html does not exist, a nice little recursive loop is ready and can spiral down your server very effectively.

Have you read the Apache logs? If glimpsing through them with text viewer of your choice does not reveal anything, try to feed your access logs to webalizer or some other analyzer and see the most accessed URLs. Also check out the error log if there's lots of repeated errors.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.