hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : mysql 100% CPU usage
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

mysql 100% CPU usage

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 05-18-2007, 03:37 PM
Zeest Zeest is offline
Newbie
 
Join Date: Jul 2006
Posts: 20

mysql 100% CPU usage


After running for a while mysql suddenly starts using 100% CPU and my site goes down due to apache waiting with 150 sleeping processes.

Here is the top stats
PHP Code:
top 00:20:47 up 12:01,  2 users,  load average1.111.040.95
Tasks
200 total,   2 running198 sleeping,   0 stopped,   0 zombie
Cpu
(s):100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem
:   1004152k total,   618132k used,   386020k free,   118436k buffers
Swap
:  2000084k total,        0k used,  2000084k free,   282372k cached

  PID USER      PR  NI  VIRT  RES  SHR S 
%CPU %MEM    TIME+  COMMAND
 2011 mysql     18   0  177m  43m 5684 S 99.9  4.5  86
:51.60 mysqld
14877 root      15   0  2360 1216  860 R  0.3  0.1   0
:00.11 top
    1 root      15   0  1948  648  556 S  0.0  0.1   0
:00.97 init 
ps ax | grep apache -c
152

On restarting mysql everything goes back to normal.

Can someone tell me how I could go about rectifying this?

I'm sure the server can take the load, coz before this the site was on a way slower machine and worked flawlessly.

Reply With Quote


Sponsored Links
  #2  
Old 05-18-2007, 03:38 PM
Zeest Zeest is offline
Newbie
 
Join Date: Jul 2006
Posts: 20
Oh btw the configuration directives and files are the default ones. I've installed everything using apt

Reply With Quote
  #3  
Old 05-18-2007, 03:51 PM
anatolijd anatolijd is offline
WHT Addict
 
Join Date: May 2007
Location: Ukraine
Posts: 161
at least you have to see what makes mysql to use all cpu resources,
use this command to see what mysql is doing:

# mysqladmin processlist

Reply With Quote
Sponsored Links
  #4  
Old 05-18-2007, 07:47 PM
Tech4server Tech4server is offline
WHT Addict
 
Join Date: Sep 2005
Posts: 138
remove mysql-server and install it again . Wierd as it is , had a same problem with my cient's server , no configuration would make it work normally , so i removed mysql and installed it again from source and it worked perfectly .

Reply With Quote
  #5  
Old 05-18-2007, 07:50 PM
Zeest Zeest is offline
Newbie
 
Join Date: Jul 2006
Posts: 20
So this time around, should I compile it myself from source?

Reply With Quote
  #6  
Old 05-18-2007, 07:53 PM
RBBOT RBBOT is offline
Web Hosting Evangelist
 
Join Date: Dec 2006
Posts: 477
What version of mysql are you using? I had this issue with 5.0.22 and 5.0.26 on an old server where CPU would jump to 100% approximately every 2-3 weeks despite no queries running against the database - show process list was empty and my admin session was the only connection. A restart was the only thing that would resolve it. I've not seen it happen since version 5.0.33 though.

Reply With Quote
  #7  
Old 05-18-2007, 10:00 PM
Zeest Zeest is offline
Newbie
 
Join Date: Jul 2006
Posts: 20
mysql -V
mysql Ver 14.12 Distrib 5.0.38, for pc-linux-gnu (i486) using readline 5.2

Reply With Quote
  #8  
Old 05-18-2007, 10:57 PM
Scott.Mc Scott.Mc is offline
Engineer
 
Join Date: Jan 2005
Location: Scotland, UK
Posts: 2,380
As you are using the default UNOPTIMIZED mySQL that is more than likely your problem.

cat /etc/my.cnf
free -m
cat /proc/cpuinfo
mysqladmin processlist

__________________
Server Management - AdminGeekZ.com
Infrastructure Management, Web Application Performance, mySQL DBA. Keep your servers online.
United Kingdom: *0800 8620073* // United States: *585 563 1729* // Australia: *02 9037 2448* // International: *+44.1412800134*
Scott Mcintyre

Reply With Quote
  #9  
Old 05-19-2007, 07:56 AM
ImageLeet ImageLeet is offline
Web Hosting Master
 
Join Date: Oct 2006
Posts: 898
mysqladmin processlist->check the open tables for account using the most.
sometimes ppl are running inefficient crons for posting stuff.

__________________
Imageleet.com - Premium Hosting Solutions Since 2006
Shared Hosting, FFmpeg Hosting, Linux VPS and Dedicated Solutions.
SSD, Litespeed powered, R1soft, cPanel | Softaculous | Rvsitebuilder + FFmpeg, Mencoder, Mplayer, Flvtool2, x264
http://www.imageleet.com

Reply With Quote
  #10  
Old 05-20-2007, 01:32 AM
Abu Mami Abu Mami is offline
cholesterol dependent
 
Join Date: Oct 2000
Location: Israel
Posts: 1,283
Check for cronjobs that are accessing mySQL. When you find a script that's runniung around the same time as your 100%CPU, get to work optimizing the queries.

From experience...
- use the LIMIT clause to limit the size of queries
- use the JOIN clause to greatly optimize queries across tables
- make sure that indexes are defined

Reply With Quote
  #11  
Old 05-20-2007, 02:30 AM
kamyana kamyana is offline
Junior Guru
 
Join Date: May 2004
Location: Pakistan
Posts: 228
can you post /etc/my.cnf ??

__________________
Cloud Hosting
~ Shared Cpanel Hosting, Cpanel Reseller, Business Cloud Hosting, SSD Cpanel Reseller Hosting ~

Reply With Quote
  #12  
Old 05-20-2007, 07:51 AM
Sys Admin Sys Admin is offline
WHT Addict
 
Join Date: Apr 2007
Posts: 132
You need to optimize your mysql & apache well.

__________________
Attacker.NET IT Security Consulting Group
Server Management | Security Hardening | Ethical Hacking/Pen-Testing.
Certified Information Security Professionals
E-mail: sales@attacker.net | http://attacker.net

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Open Data Center Alliance Adds Frameworks for Software Entitlement, Data Security Web Hosting News 2013-03-14 15:33:01
Open Data Center Alliance Releases Security-Focused Cloud Computing Usage Models Web Hosting News 2012-04-05 15:04:50
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43
SSL Certificate Authority GlobalSign Launches CloudSSL Product Web Hosting News 2011-08-12 19:33:59


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?