LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 04-10-2012, 08:24 AM   #1
nekkro-kvlt
LQ Newbie
 
Registered: May 2009
Posts: 20

Rep: Reputation: 0
slow apache 2 performances, even with small amount of traffic.


Hi all,

I have terrible performances with my apache server... Meaning when I display my website (just my personnal blog with max 100/200 visitors per day), it can take sometime up to 5s for the apache process to send the data.
I'm using
Code:
root@ksxxx:~# apache2ctl -v
Server version: Apache/2.2.16 (Debian)
Server built:   Feb  5 2012 21:35:42
root@ksxxx:~# uname -r
2.6.38.2-grsec-xxxx-grs-ipv6-64
If I check the apache processes, it goes very high when I display my blog (wordpress based blog)

If I use top while reloading the page, I can see apache process going up to 60%.

I have iptables, and I tried to disable it with same result.

Here's a sample of my server status:
Code:
Server Built: Feb 5 2012 21:35:42

Current Time: Tuesday, 10-Apr-2012 14:20:43 CEST
Restart Time: Tuesday, 10-Apr-2012 13:31:35 CEST
Parent Server Generation: 6
Server uptime: 49 minutes 8 seconds
Total accesses: 1179 - Total Traffic: 145.5 MB
CPU Usage: u377.8 s16.77 cu0 cs0 - 13.4% CPU load
.4 requests/sec - 50.6 kB/second - 126.4 kB/request
6 requests currently being processed, 5 idle workers

W_K.KCK__K.__...................................................
................................................................
................................................................
................................................................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

Srv	PID	Acc	M	CPU 	SS	Req	Conn	Child	Slot	Client	VHost	Request
0-6	3752	1/17/116	W 	3.17	0	0	1.7	16.65	17.54 	1.2.3.4	status.domain1.fr	GET / HTTP/1.1
1-6	5579	0/0/96	_ 	6.15	4	0	0.0	0.00	0.32 	::1	xxx.kimsufi.com	OPTIONS * HTTP/1.0
2-6	4258	3/12/105	K 	4.71	3	50	48.1	0.05	12.95 	1.2.3.4	www.domain2.fr	GET /wp-content/plugins/wp-cumulus/tagcloud.swf?r=329402 HTTP/1
3-6	-	0/0/123	. 	79.03	64	0	0.0	0.00	0.63 	::1	xxx.kimsufi.com	OPTIONS * HTTP/1.0
4-6	5051	2/7/105	K 	1.16	5	1	1.2	0.11	3.07 	1.2.3.4	www.domain2.fr	GET /wp-content/plugins/jetpack/modules/wpgroho.js?ver=3.3.1 HT
5-6	1259	1/34/147	C 	8.98	0	1045	0.0	0.23	1.99 	4.5.6.7	www.domain2.fr	GET /feed/ HTTP/1.1
6-6	30845	1/105/107	K 	87.34	5	58	32.4	106.80	106.80 	1.2.3.4	www.domain2.fr	GET /wp-includes/js/jquery/jquery.js?ver=1.7.1 HTTP/1.1
7-6	5116	0/2/66	_ 	0.01	58	20	0.0	0.00	0.31 	109.7.28.172	www.domain2.fr	GET /favicon.ico HTTP/1.1
8-6	31460	0/115/118	_ 	77.82	64	8	0.0	0.87	0.87 	5.6.7.8	www.domain2.fr	GET /favicon.ico HTTP/1.1
9-6	31461	1/83/86	K 	84.75	5	1	0.6	0.39	0.42 	1.2.3.4	www.domain2.fr	GET /wp-content/plugins/wp-polls/polls-js.js?ver=2.50 HTTP/1.1
10-6	-	0/0/66	. 	40.30	63	0	0.0	0.00	0.34 	::1	xxx.kimsufi.com	OPTIONS * HTTP/1.0
11-6	5117	0/1/25	_ 	0.00	37	1	0.0	0.00	0.11 	127.0.0.1	xxx.kimsufi.com	GET / HTTP/1.0
12-6	5118	0/1/14	_ 	0.00	4	2	0.0	0.00	0.13 	1.2.3.4	status.domain1.fr	GET / HTTP/1.1
13-6	-	0/0/5	. 	1.15	1720	0	0.0	0.00	0.07 	::1	xxx.kimsufi.com	OPTIONS * HTTP/1.0
took a TCPDUmp, and we clearly see a 2s delay for the reply (changed the IP, 2.2.2.2 is the server here)

Code:
14:22:50.351053 IP 1.1.1.1.18070 > 2.2.2.2.80: Flags [S], seq 2817311685, win 65535, options [mss 1460,nop,wscale 3,sackOK,TS val 338753766 ecr 0], length 0
14:22:50.351215 IP 2.2.2.2.80 > 1.1.1.1.18070: Flags [S.], seq 1020420939, ack 2817311686, win 14480, options [mss 1460,sackOK,TS val 2891083 ecr 338753766,nop,wscale 7], length 0
14:22:50.365968 IP 1.1.1.1.18070 > 2.2.2.2.80: Flags [.], ack 1, win 16471, options [nop,nop,TS val 338753767 ecr 2891083], length 0
14:22:50.366059 IP 1.1.1.1.18070 > 2.2.2.2.80: Flags [P.], seq 1:529, ack 1, win 16471, options [nop,nop,TS val 338753767 ecr 2891083], length 528
14:22:50.366116 IP 2.2.2.2.80 > 1.1.1.1.18070: Flags [.], ack 529, win 122, options [nop,nop,TS val 2891086 ecr 338753767], length 0
14:22:52.132329 IP 2.2.2.2.80 > 1.1.1.1.18070: Flags [.], seq 1:1449, ack 529, win 122, options [nop,nop,TS val 2891528 ecr 338753767], length 1448
14:22:52.132373 IP 2.2.2.2.80 > 1.1.1.1.18070: Flags [.], seq 1449:2897, ack 529, win 122, options [nop,nop,TS val 2891528 ecr 338753767], length 1448
14:22:52.132398 IP 2.2.2.2.80 > 1.1.1.1.18070: Flags [.], seq 2897:4345, ack 529, win 122, options [nop,nop,TS val 2891528 ecr 338753767], length 1448
14:22:52.147873 IP 1.1.1.1.18070 > 2.2.2.2.80: Flags [.], ack 1449, win 16290, options [nop,nop,TS val 338753945 ecr 2891528], length 0
Any idea what I could check ?

Last edited by nekkro-kvlt; 04-10-2012 at 08:27 AM.
 
Old 04-10-2012, 04:06 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,590

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Quote:
Originally Posted by nekkro-kvlt View Post

If I check the apache processes, it goes very high when I display my blog (wordpress based blog)
That is your problem(wordpress). I worked for the biggest web host provider in the u.s. and I got several hundred tickets to optimize apache & MySQL due to slow performance. The cause is always these open source applications like Joomla and WordPress. You need to look at web page optimization, try your site at www.webpagetest.org and see how bad it reports. You will need to do CSS compression, look at indexing your MySQL queries(THIS IS THE HUGEST CAUSE OF CPU UTIL AND SLOWNESS ISSUES) and remove any plugins that are problematic.

If you don't believe me go download a static CSS/HTML template from any of the free template sites out there and see how fast your site loads.

Pay attention to your TTFB(Time To First Byte) as this is going to tell you how long it takes Apache/MySQL to process the request and start sending data back, this is usually greater than 5-6 seconds with any WordPress site due to the excessively slow MySQL queries, if you enable slow query logging in your my.cf file you will more than likely see queries being executed on the database that are examining hundreds of thousands of rows and taking 10+ seconds to complete.

Hope this helps point you in the right direction, I know its not the answer you want but its more than likely the correct one.
 
Old 04-10-2012, 04:43 PM   #3
nekkro-kvlt
LQ Newbie
 
Registered: May 2009
Posts: 20

Original Poster
Rep: Reputation: 0
Hi,

Thanks for your valuable answer.

I checked the output of this site, and I get basically the same than with firebug... Meaning approx 3s for the first byte... Any pointers on how to optimize MySQL Queries ?? I'm more a network guy than a linux admin guy so

Edit:
I found this site:
http://www.prelovac.com/vladimir/wor...mization-guide

That seems to five some pointers already

Last edited by nekkro-kvlt; 04-10-2012 at 04:45 PM.
 
Old 04-10-2012, 04:47 PM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,590

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
First enable slow query logging to figure out where your biggest choking point is. dev.mysql.com/doc/en/slow-query-log.html you will more than likely identify some queries that are pulling data from certain plugin tables that you can disable to improve performance. Basically what happens with these apps is that there is no indexes used for pulling the data and the structure of the query will cause an extreme amount of rows to be examined, say it is selecting * from one table where something = a and selecting * from another table where something = b. If you have 100 rows in table 1 and 100 rows in table 2 that match that criteria MySQL will create every possible combination of the two for the final examination, meaning that you started off with 200 rows but MySQL will examine 10,000(100*100). Creating indexes or removing erroneous rows of data from your tables can significantly decrease this from happening.
 
Old 01-15-2014, 12:38 AM   #5
arafathhashmi
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
Smile

I faced the similar kind of issue with Apache, it seems like the Apache is reserving memory (RAM) for prefork processes, you need to tweak the prefork setting in the apache config, I think this below tutorial could help you in doing this..

http://www.hostocol.in/base/apache/optime-apache-for-better-performance-and-ram-usage/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unusual amount of incoming traffic on eth0 svenito Linux - Security 17 05-09-2010 07:48 AM
Record / Monitor amount of traffic a user has used for ssh tunnelling? iamacup Linux - Networking 2 12-28-2009 03:53 PM
copying a huge amount of small files, on a live system xxxx Linux - General 12 04-15-2008 03:53 AM
generate large amount of traffic data Mr_C Linux - Networking 3 03-10-2006 12:38 AM


All times are GMT -5. The time now is 03:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration