LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-30-2007, 04:39 AM   #1
nyttoc
LQ Newbie
 
Registered: Apr 2007
Posts: 7

Rep: Reputation: 0
apache + php + mysql -> CPU EATING


hello

i have 10 computers and each of these computers is doing 20 mysql queries (via php) at the same time (simultaneous) every 5 seconds, however i see that apache is eating my CPU sooo much, is that because allow_persistent for mysql is set in php.ini? or what could be the problem with mysql?.. if i don't do a query to mysql with my php file it doesnt eat my cpu... help!
 
Old 05-01-2007, 01:38 PM   #2
rcase5
Member
 
Registered: Apr 2004
Distribution: Fedora & Debian
Posts: 38

Rep: Reputation: 15
More info please

The answer depends on a lot of things.

What are the specs on these systems? If these systems are Pentiums, I would say that high CPU utilization would be expected under the circumstances you stated. But if they're relatively new Intel Core 2 or AMD Opteron, then that would be a different story.

Also, how big is the database, and what kinds of transactions are being performed? Are these queries updates or inserts, or are there more selects? How complex are the queries? How big is the database? Also, is this database replicated to each of the individual systems or do they reside on one system? If that's the case, the access latency could be a problem.

As for your specific question, I wouldn't think MySQL settings would necessarily affect the amount of CPU Apache takes except for any operations specifically related to MySQL. The 'persistent connections' setting in MySQL is actually designed to improve performance by reducing the need to make new connections every time a web site makes an access to the database. You could try turning off the setting and see if it makes a difference.
 
Old 05-02-2007, 03:32 AM   #3
nyttoc
LQ Newbie
 
Registered: Apr 2007
Posts: 7

Original Poster
Rep: Reputation: 0
my query is quite simple, but the problem is that 10 computers are accessing my web server at the same time...... Each computer accesses the same php file which is doing a myqsl query and this 20 times simulteneously (i do this for home automation)... so i have about 200 php pages requests at the same time (via AJAX/XMLHTTPREQUEST) to a mysql table, and this causes a huge CPU load of apache. if i don't do a query in that php file i don't have a cpu load so high.. so i think it's normal that my cpu load is so high...

the server has a 1000MHz VIA C3 CPU with 256 MB memory and 500 MB swap file.
 
Old 05-02-2007, 07:58 AM   #4
fooks
Member
 
Registered: Jan 2007
Location: Ukraine
Posts: 47

Rep: Reputation: 15
you may check what mysql is doing at any time:

Code:
# mysqladmin processlist -u root -p
Enter password:

+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 5  | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+
 
  


Reply



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
kacpid eating cpu 99% cpu time! tjclancy Linux - Software 13 09-19-2011 03:08 PM
apache 2.0 + PHP 5 + heavy cpu load nyttoc Linux - Server 1 04-26-2007 06:59 AM
XFS is eating my CPU xKintaro Debian 0 09-27-2005 09:01 AM
ksoftirqd eating >60% of my CPU subaruwrx Fedora 0 09-22-2004 01:10 AM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 08:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:01 AM.

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
Open Source Consulting | Domain Registration