banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Forum Index Thảo luận hệ điều hành *nix Mysql tự nhiên ngốn CPU, Apache vượt max client allowed  XML
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 08/05/2013 11:57:15 (+0700) | #1 | 275564
dungnguyen31
Member

[Minus]    0    [Plus]
Joined: 27/07/2007 11:29:48
Messages: 7
Offline
[Profile] [PM]

Từ tối hôm qua, server mình liên tục gặp tình trạng như sau :



Mình kiểm tra trong /var/log/httpd/error_log thì thấy thông báo sau

Code:
[Tue May 07 00:30:46 2013] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.3.23 SVN/1.6.11 configured -- resuming normal operations
[color=red][Tue May 07 00:32:00 2013] [error] server reached MaxClients setting, consider raising the MaxClients setting[/color]
[Tue May 07 00:34:25 2013] [notice] caught SIGTERM, shutting down
[Tue May 07 00:37:26 2013] [notice] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Tue May 07 00:37:26 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)


Mình thử dùng
Code:
[root@localhost ~]# netstat -n | grep :80 |wc -l

thì nhận được kết quả là
Code:
3204


Kiểm tra trong Access_Log thì các request đến có vẻ rất hợp lệ. Tuy nhiên Mysql luôn sử dụng gần 300% CPU.
Trước đây thì load average của server chỉ >=1, idle CPU khoảng 60%, hiện giờ thì load average giao động trong khoảng 5-25, used CPU tăng lên tới >=60%.

Đây là file my.cnf mình đang sử dụng

Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

long_query_time=3
log_slow_queries=/var/log/mysqldslow.log

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
max_connections=400
wait_timeout=10
connect_timeout=10
max_allowed_packet=8829440


Nhờ mọi người trợ giúp. Xin cảm ơn.
[Up] [Print Copy]
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 08/05/2013 14:05:26 (+0700) | #2 | 275566
[Avatar]
dexxa
Member

[Minus]    0    [Plus]
Joined: 01/07/2006 20:35:01
Messages: 121
Offline
[Profile] [PM]

cat /var/log/mysqldslow.log
 

Rồi show lên mình xem thử. Có thể 1 câu query nào đó đang gây ra tình trạng này
[Up] [Print Copy]
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 08/05/2013 15:15:45 (+0700) | #3 | 275567
dungnguyen31
Member

[Minus]    0    [Plus]
Joined: 27/07/2007 11:29:48
Messages: 7
Offline
[Profile] [PM]
Đây là 2 câu slow query trong bộ source do bên mình tự viết
Code:
# Time: 130507 17:08:16
# User@Host: hd_music[hd_music] @ localhost []
# Query_time: 11.073757  Lock_time: 0.000152 Rows_sent: 0  Rows_examined: 1522037
SET timestamp=1367921296;
SELECT un.un_id, gc.ac_id,gc.ac_groupid,gc.ac_content,g.group_code,g.group_name
				FROM table_mem_group_activities AS gc 
				INNER JOIN table_user_notification AS un ON un.un_itemid = gc.ac_id
				INNER JOIN table_mem_group AS g ON g.group_id = gc.ac_groupid 
				WHERE un_ownerid='54741' AND gc.is_newnotify = 1 AND  un.is_newnotify = 1
				ORDER BY un.un_id ASC LIMIT 0,1;
# Time: 130507 17:09:07
# User@Host: hd_music[hd_music] @ localhost []
# Query_time: 22.075552  Lock_time: 0.000199 Rows_sent: 10  Rows_examined: 722666
SET timestamp=1367921347;
SELECT DISTINCT mg.group_id, mg.group_name, mg.group_code, mg.group_logo, rs.tongtv AS tongtv
				FROM table_mem_group AS mg
				INNER JOIN (select ac_groupid,is_newest from table_mem_group_activities order by is_newest DESC) AS mga ON mga.ac_groupid = mg.group_id  
				INNER JOIN (select DISTINCT group_id, count(member_id) AS tongtv FROM table_mem_ref_group WHERE `status`=2 GROUP BY group_id) AS rs ON rs.group_id = mg.group_id AND mg.filter !=8
				ORDER BY mga.is_newest DESC LIMIT 0,10;

Đây là một câu slow query trong bộ source vbulletin.
Code:
# Time: 130507 19:31:40
# User@Host: root[root] @ localhost []
# Query_time: 16.609280  Lock_time: 0.003681 Rows_sent: 30  Rows_examined: 877922
use vbbed;
SET timestamp=1367929900;
SELECT user.*,usertextfield.*,userfield.*, user.userid, options,
			IF(user.displaygroupid=0, user.usergroupid, user.displaygroupid) AS displaygroupid, infractiongroupid
		
		,avatar.avatarpath,NOT ISNULL(customavatar.userid) AS hascustomavatar,customavatar.dateline AS avatardateline, customavatar.width AS avwidth, customavatar.height AS avheight
		
		 , IF((options & 512 AND user.userid <> 0), 0, lastactivity) AS lastvisittime 
		
		
		
		FROM user AS user
		LEFT JOIN usertextfield AS usertextfield ON(usertextfield.userid=user.userid)
		LEFT JOIN userfield AS userfield ON(userfield.userid=user.userid)
		
		LEFT JOIN avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN customavatar AS customavatar ON(customavatar.userid = user.userid)
		
		
		
		WHERE 1=1
			AND (user.usergroupid IN (-1,6,7,2,5))
			
		ORDER BY user.posts desc 
		LIMIT 214650, 30;

Trước đây thì không có tình trạng như thế này, vẫn các câu query như vậy nhưng thời gian execute rất nhanh, mới chỉ bắt đầu từ hôm 07/05/2013 là rơi vào tình trạng này.
[Up] [Print Copy]
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 08/05/2013 17:39:07 (+0700) | #4 | 275572
dungnguyen31
Member

[Minus]    0    [Plus]
Joined: 27/07/2007 11:29:48
Messages: 7
Offline
[Profile] [PM]
Code:
OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8
536.25"
118.71.223.76 - - [08/May/2013:18:31:35 +0700] "GET /lession/58/favicon.ico HTTP
/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like G
ecko) Chrome/26.0.1410.64 Safari/537.31"
123.21.172.248 - - [08/May/2013:18:31:35 +0700] "GET /video/8974/favicon.ico HTT
P/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML
, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
111.249.151.126 - - [08/May/2013:18:31:35 +0700] "GET /video/10614/favicon.ico H
TTP/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; rv:20.0) Gecko/20100101 Firefo
x/20.0"
123.24.40.218 - - [08/May/2013:18:31:35 +0700] "GET /vbb8/showthread.php?p=17740
9 HTTP/1.1" 200 51298 "-" "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101
Firefox/20.0"
113.165.46.98 - - [08/May/2013:18:31:35 +0700] "GET /lession/932/favicon.ico HTT
P/1.1" 200 118185 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, l
ike Gecko) Chrome/26.0.1410.64 Safari/537.31"
118.68.42.81 - - [08/May/2013:18:31:35 +0700] "GET /uploads/imglession/small_262
7927cefc55891ff76c41cd28f04da.jpg HTTP/1.1" 200 11215 "http://hocdan.com/" "Mozi
lla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko
) Version/6.0 Mobile/10B329 Safari/8536.25"
::1 - - [08/May/2013:18:31:35 +0700] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.
15 (CentOS) (internal dummy connection)"
113.23.81.211 - - [08/May/2013:18:31:35 +0700] "GET /lyric/639/favicon.ico HTTP/
1.1" 200 105575 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, lik
e Gecko) Chrome/26.0.1410.64 Safari/537.31"
202.189.72.208 - - [08/May/2013:18:31:35 +0700] "GET /lession/1087/favicon.ico H
TTP/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHT
ML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
207.241.237.107 - - [08/May/2013:18:31:35 +0700] "GET /vbb8/sendmessage.php?do=s
endtofriend&t=44268 HTTP/1.0" 200 29316 "http://hocdan.com/vbb8/showthread.php?p
=156969" "Mozilla/5.0 (compatible; archive.org_bot +http://www.archive.org/detai
ls/archive.org_bot)"
58.187.225.167 - - [08/May/2013:18:31:35 +0700] "GET /lyric/935/favicon.ico HTTP
/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML,
 like Gecko) Chrome/26.0.1410.64 Safari/537.31"
42.117.114.65 - - [08/May/2013:18:31:35 +0700] "GET /vbb8/register.php HTTP/1.1"
 503 3037 "http://www.youtube.com/watch?v=BZneKL6uSso&list=PL60B837707ABCDF47" "
Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0"
42.119.69.102 - - [08/May/2013:18:31:35 +0700] "GET /lyric/88/favicon.ico HTTP/1
.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, l
ike Gecko) Chrome/26.0.1410.64 Safari/537.31"
118.68.42.81 - - [08/May/2013:18:31:35 +0700] "GET /common/images/no-image.jpg H
TTP/1.1" 200 4756 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac
 OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8
536.25"
66.249.77.81 - - [08/May/2013:18:31:35 +0700] "GET /lyric/692/kiep-rong-buon HTT
P/1.1" 200 28 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.co
m/bot.html)"
58.187.62.235 - - [08/May/2013:18:31:35 +0700] "GET /lyric/3856/favicon.ico HTTP
/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML,
 like Gecko) Chrome/26.0.1410.64 Safari/537.31"
27.66.133.95 - - [08/May/2013:18:31:35 +0700] "GET /lyric/129/oi-que-toi HTTP/1.
1" 200 28 "http://www.google.com.vn/search?client=ms-android-samsung&hl=en&sourc
e=android-browser-type&v=133247963&ei=KjeKUd3TEcS4rAfW04H4Dg&q=%C3%B4i+qu%C3%AA+
t%C3%B4i+tab&oq=%C3%B4i+qu%C3%AA+t%C3%B4i+tab&gs_l=mobile-gws-serp.12..0j0i22i30
l3.7705.10810.1.14040.7.7.0.0.0.0.2450.2450.9-1.1.0...0.0...1c.1.12.mobile-gws-s
erp.bpf5Ul5_eUI" "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; GT-S5360 Build/GI
NGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
"
117.3.65.117 - - [08/May/2013:18:31:35 +0700] "GET /lession/777/favicon.ico HTTP
/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Ge
cko) Chrome/16.0.912.63 Safari/535.7"
42.119.121.152 - - [08/May/2013:18:31:35 +0700] "GET /lession/209/favicon.ico HT
TP/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like
 Gecko) Chrome/26.0.1410.64 Safari/537.31"
14.161.5.223 - - [08/May/2013:18:31:35 +0700] "GET /video/10612/favicon.ico HTTP
/1.1" 200 101629 "-" "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.31 (KHTML, li
ke Gecko) Chrome/26.0.1410.64 Safari/537.31"
113.182.67.182 - - [08/May/2013:18:31:36 +0700] "GET /lession/658/favicon.ico HT
TP/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTM
L, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
195.19.48.129 - - [08/May/2013:18:31:36 +0700] "GET /video/10611/favicon.ico HTT
P/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML
, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
113.162.182.118 - - [08/May/2013:18:31:35 +0700] "GET /lyric/4824/favicon.ico HT
TP/1.1" 200 110428 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML,
like Gecko) Chrome/26.0.1410.64 Safari/537.31"
118.71.8.3 - - [08/May/2013:18:31:35 +0700] "GET /lyric/1279/favicon.ico HTTP/1.
1" 200 112151 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like
Gecko) Chrome/26.0.1410.64 Safari/537.31"
123.21.172.248 - - [08/May/2013:18:31:35 +0700] "GET /video/10573/favicon.ico HT
TP/1.1" 200 101830 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (
KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
123.27.54.114 - - [08/May/2013:18:31:36 +0700] "GET /index.php?act=searchresult&
kw=haketu HTTP/1.1" 200 87144 "http://hocdan.com/" "Mozilla/5.0 (Windows NT 5.1)
 AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
118.68.42.81 - - [08/May/2013:18:31:36 +0700] "GET /common/images/gotop.gif HTTP
/1.1" 200 581 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS
X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.
25"
118.68.42.81 - - [08/May/2013:18:31:36 +0700] "GET /common/images/loading_animat
ion.gif HTTP/1.1" 200 4912 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU OS 6_1_3
 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329
 Safari/8536.25"
118.68.42.81 - - [08/May/2013:18:31:36 +0700] "GET /vbb8/image.php?u=71851&datel
ine=1359649931 HTTP/1.1" 200 5032 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU O
S 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile
/10B329 Safari/8536.25"
::1 - - [08/May/2013:18:31:36 +0700] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.
15 (CentOS) (internal dummy connection)"
111.249.151.126 - - [08/May/2013:18:31:36 +0700] "POST /templates/comment_ajax.p
hp HTTP/1.1" 200 329 "http://hocdan.com/video/10614/dont-stop-me-now-guitar-sand
ra-bae" "Mozilla/5.0 (Windows NT 6.1; rv:20.0) Gecko/20100101 Firefox/20.0"
123.30.175.79 - - [08/May/2013:18:31:36 +0700] "GET /place/tags/sieu-thi-an-duon
g HTTP/1.1" 200 36206 "-" "coccoc"
1.53.72.76 - - [08/May/2013:18:31:36 +0700] "GET /lyric/381/favicon.ico HTTP/1.1
" 200 106086 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537
.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31"
123.27.54.114 - - [08/May/2013:18:31:36 +0700] "GET /common/images/duca.jpg HTTP
/1.1" 200 32454 "http://hocdan.com/index.php?act=searchresult&kw=haketu" "Mozill
a/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.6
4 Safari/537.31"
118.68.42.81 - - [08/May/2013:18:31:36 +0700] "GET /uploads/imglession/small_7c2
42bcf5c7d743d6732c771385a3c70.jpg HTTP/1.1" 200 20867 "http://hocdan.com/" "Mozi
lla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko
) Version/6.0 Mobile/10B329 Safari/8536.25"
27.3.42.3 - - [08/May/2013:18:31:36 +0700] "GET /lyric/3944/favicon.ico HTTP/1.1
" 200 110066 "-" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.31 (KHTML, like G
ecko) Chrome/26.0.1410.64 Safari/537.31"
113.182.67.182 - - [08/May/2013:18:31:36 +0700] "GET /guru/72179/favicon.ico HTT
P/1.1" 200 90983 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KH
TML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
123.21.172.248 - - [08/May/2013:18:31:36 +0700] "GET /video/10572/favicon.ico HT
TP/1.1" 200 101578 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (
KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
118.68.42.81 - - [08/May/2013:18:31:37 +0700] "GET /uploads/imglession/small_938
f2f48b1905724f1822dec3126422b.jpg HTTP/1.1" 200 14927 "http://hocdan.com/" "Mozi
lla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko
) Version/6.0 Mobile/10B329 Safari/8536.25"
1.53.229.223 - - [08/May/2013:18:31:37 +0700] "GET /lyric/2286/favicon.ico HTTP/
1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Ge
cko) Chrome/26.0.1410.64 Safari/537.31"
202.156.14.103 - - [08/May/2013:18:31:37 +0700] "GET /lession/119/favicon.ico HT
TP/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTM
L, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
123.30.175.79 - - [08/May/2013:18:31:37 +0700] "GET /place/tags/sieu-thi-an-phu
HTTP/1.1" 200 36206 "-" "coccoc"
117.7.125.183 - - [08/May/2013:18:31:37 +0700] "GET /lyric/5196/favicon.ico HTTP
/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML,
 like Gecko) Chrome/26.0.1410.64 Safari/537.31"
123.22.82.211 - - [08/May/2013:18:31:37 +0700] "GET /lyric/1575/favicon.ico HTTP
/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like G
ecko) Chrome/26.0.1410.64 Safari/537.31"
123.20.253.229 - - [08/May/2013:18:31:37 +0700] "GET /lyric/3818/favicon.ico HTT
P/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML
, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
171.255.0.150 - - [08/May/2013:18:31:37 +0700] "GET /uploads/imglession/small_56
b1bfa8bc40f319e9542ca89b526bd2.jpg HTTP/1.1" 304 - "http://hocdan.com/" "Mozilla
/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64
 Safari/537.31"
157.56.93.153 - - [08/May/2013:18:31:36 +0700] "GET /lyric/73/cau-vong-khuyet HT
TP/1.1" 200 109070 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.c
om/bingbot.htm)"
58.186.130.97 - - [08/May/2013:18:31:36 +0700] "GET /lyric/1767/favicon.ico HTTP
/1.1" 200 107996 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, li
ke Gecko) Chrome/26.0.1410.64 Safari/537.31"
118.68.42.81 - - [08/May/2013:18:31:37 +0700] "GET /common/images/blank.gif HTTP
/1.1" 200 43 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X
) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.2
5"
123.30.175.79 - - [08/May/2013:18:31:37 +0700] "GET /place/tags/sieu-thi-aromart
 HTTP/1.1" 200 36206 "-" "coccoc"
58.186.16.159 - - [08/May/2013:18:31:34 +0700] "GET /lyric/1345/favicon.ico HTTP
/1.1" 200 110976 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, li
ke Gecko) Chrome/26.0.1410.64 Safari/537.31"
123.20.71.89 - - [08/May/2013:18:31:37 +0700] "GET /lyric/5233/favicon.ico HTTP/
1.1" 200 108455 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, lik
e Gecko) Chrome/26.0.1410.64 Safari/537.31"
66.249.77.81 - - [08/May/2013:18:31:37 +0700] "GET /lyric/1406/moi-tinh-dau HTTP
/1.1" 200 106239 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google
.com/bot.html)"
118.68.42.81 - - [08/May/2013:18:31:37 +0700] "GET /common/images/closelabel.png
 HTTP/1.1" 200 168 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU OS 6_1_3 like Ma
c OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/
8536.25"
66.249.77.86 - - [08/May/2013:18:31:37 +0700] "GET /place/on_street/ngan-hang-va
-atm/diem-dat-atm/0/function.include2103253233422222222/8 HTTP/1.1" 200 39263 "-
" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
::1 - - [08/May/2013:18:31:37 +0700] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.
15 (CentOS) (internal dummy connection)"
123.30.175.79 - - [08/May/2013:18:31:37 +0700] "GET /place/tags/sieu-thi-cat-lin
h HTTP/1.1" 200 36206 "-" "coccoc"
123.24.40.218 - - [08/May/2013:18:31:37 +0700] "GET /vbb8/clientscript/vbulletin
_important.css?v=387 HTTP/1.1" 304 - "http://hocdan.com/vbb8/showthread.php?p=17
7409" "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0"
113.23.81.117 - - [08/May/2013:18:31:37 +0700] "GET /common/css/style.css?rid=15
59 HTTP/1.1" 304 - "http://hocdan.com/lession/607/" "Mozilla/5.0 (Windows NT 5.1
; rv:20.0) Gecko/20100101 Firefox/20.0"
58.26.207.170 - - [08/May/2013:18:31:37 +0700] "GET /lession/1032/favicon.ico HT
TP/1.1" 200 100442 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (
KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
27.2.99.95 - - [08/May/2013:18:31:37 +0700] "GET /lyric/15/co-hang-xom HTTP/1.1"
 200 110778 "http://www.google.com.vn/url?sa=t&rct=j&q=tab%20co%20hang%20xom&sou
rce=web&cd=1&cad=rja&sqi=2&ved=0CCsQFjAA&url=http%3A%2F%2Fhocdan.com%2Flyric%2F1
5%2Fco-hang-xom&ei=gTeKUZWeCYjzlAWXmIGYAw&usg=AFQjCNH0CI6am4sThzdLgIqHLC4H4b5Ubg
&bvm=bv.46226182,d.dGI" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31
(KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
113.23.81.117 - - [08/May/2013:18:31:36 +0700] "GET /lession/607/ HTTP/1.1" 200
118219 "http://www.google.com.vn/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rj
a&sqi=2&ved=0CEIQFjAD&url=http%3A%2F%2Fhocdan.com%2Flession%2F607%2F&ei=gTeKUf2Y
HsSZiQf2-oDgCQ&usg=AFQjCNFjAdABrNnvgVLUjjKlt5gb3UG0Yw&bvm=bv.46226182,d.aGc" "Mo
zilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0"
113.23.81.117 - - [08/May/2013:18:31:37 +0700] "GET /vbb8/clientscript/vbulletin
_md5.js?v=387 HTTP/1.1" 304 - "http://hocdan.com/lession/607/" "Mozilla/5.0 (Win
dows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0"
123.30.175.79 - - [08/May/2013:18:31:37 +0700] "GET /place/tags/sieu-thi-cau-gia
y HTTP/1.1" 200 36206 "-" "coccoc"
207.241.237.235 - - [08/May/2013:18:31:37 +0700] "GET /vbb8/showthread.php?p=143
321&mode=linear HTTP/1.0" 200 40111 "http://hocdan.com/vbb8/showthread.php?mode=
hybrid&t=35052" "Mozilla/5.0 (compatible; archive.org_bot +http://www.archive.or
g/details/archive.org_bot)"
27.2.99.95 - - [08/May/2013:18:31:37 +0700] "GET /lyric/15/favicon.ico HTTP/1.1"
 200 110416 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML,
like Gecko) Chrome/26.0.1410.64 Safari/537.31"
113.23.81.117 - - [08/May/2013:18:31:38 +0700] "GET /forum/index.php?action=dlat
tach;attach=89;type=avatar HTTP/1.1" 200 33711 "http://hocdan.com/lession/607/"
"Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0"
113.23.81.117 - - [08/May/2013:18:31:38 +0700] "GET /lession/607/favicon.ico HTT
P/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/
20.0"
118.71.117.156 - - [08/May/2013:18:31:38 +0700] "GET /lyric/5233/favicon.ico HTT
P/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like
Gecko) Chrome/26.0.1410.64 Safari/537.31"
42.114.184.141 - - [08/May/2013:18:31:38 +0700] "GET /lyric/809/favicon.ico HTTP
/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like G
ecko) Chrome/26.0.1410.64 Safari/537.31"
123.30.175.79 - - [08/May/2013:18:31:38 +0700] "GET /place/tags/sieu-thi-charmvi
t-grand HTTP/1.1" 200 36206 "-" "coccoc"
113.165.101.13 - - [08/May/2013:18:31:38 +0700] "GET /video/10608/nhac-khuc-tang
-cha HTTP/1.1" 200 28 "https://www.facebook.com/" "Mozilla/5.0 (Windows NT 5.1)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.73 Safari/537.36"
58.187.66.97 - - [08/May/2013:18:31:37 +0700] "GET /lession/887/favicon.ico HTTP
/1.1" 200 107341 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, li
ke Gecko) Chrome/26.0.1410.64 Safari/537.31"
118.68.42.81 - - [08/May/2013:18:31:38 +0700] "GET /common/images/freeLessonsBox
Repeat.png HTTP/1.1" 200 2862 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU OS 6_
1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B
329 Safari/8536.25"
113.163.137.132 - - [08/May/2013:18:31:37 +0700] "GET /lyric/4452/con-mua-ngang-
qua HTTP/1.1" 200 114210 "http://www.google.com.vn/url?sa=f&rct=j&url=http://hoc
dan.com/lyric/4452/con-mua-ngang-qua&q=hop+am+con+mua+ngang+qua&ei=kjeKUdbJKILAl
QWvroDQAg&usg=AFQjCNGJPoDxmfft_Hw7OsldfC61Hji5vQ" "Mozilla/5.0 (Windows NT 5.1)
AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19"
118.68.42.81 - - [08/May/2013:18:31:38 +0700] "GET /common/images/freeLessonsBox
Link.png HTTP/1.1" 200 933 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU OS 6_1_3
 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329
 Safari/8536.25"
113.182.96.233 - - [08/May/2013:18:31:38 +0700] "GET /lessions/favicon.ico HTTP/
1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gec
ko) Chrome/15.0.874.106 Safari/535.2"
113.181.192.18 - - [08/May/2013:18:31:37 +0700] "GET /video/10609/favicon.ico HT
TP/1.1" 200 101565 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML,
like Gecko) Chrome/26.0.1410.64 Safari/537.31"
115.73.63.144 - - [08/May/2013:18:31:38 +0700] "GET /lyric/287/favicon.ico HTTP/
1.1" 200 108507 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, lik
e Gecko) Chrome/26.0.1410.64 Safari/537.31"
1.52.130.237 - - [08/May/2013:18:31:38 +0700] "GET /lyric/5233/favicon.ico HTTP/
1.1" 200 108319 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, lik
e Gecko) Chrome/26.0.1410.64 Safari/537.31"
27.69.216.120 - - [08/May/2013:18:31:38 +0700] "GET /upload/place/1032012/thumb_
1424184.jpg.jpg HTTP/1.1" 200 12166 "https://www.google.com.vn/" "Mozilla/5.0 (i
Pad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/26
.0.1410.50 Mobile/10B329 Safari/8536.25"
123.30.175.79 - - [08/May/2013:18:31:38 +0700] "GET /place/tags/sieu-thi-cmart H
TTP/1.1" 200 36206 "-" "coccoc"
180.76.5.185 - - [08/May/2013:18:31:38 +0700] "GET /user/7718/hoanaudio/comment
HTTP/1.1" 200 83719 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.b
aidu.com/search/spider.html)"
118.68.42.81 - - [08/May/2013:18:31:38 +0700] "GET /common/images/icons_activity
22.png HTTP/1.1" 200 7188 "http://hocdan.com/" "Mozilla/5.0 (iPad; CPU OS 6_1_3
like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329
Safari/8536.25"
113.190.137.36 - - [08/May/2013:18:31:38 +0700] "GET /video/10612/favicon.ico HT
TP/1.1" 200 28 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTM
L, like Gecko) Chrome/26.0.1410.64 Safari/537.31"
113.163.137.132 - - [08/May/2013:18:31:38 +0700] "POST /templates/comment_ajax.p
hp HTTP/1.1" 200 28 "http://hocdan.com/lyric/4452/con-mua-ngang-qua" "Mozilla/5.
0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 S
afari/535.19"
101.99.25.16 - - [08/May/2013:18:31:35 +0700] "GET /lession/29/favicon.ico HTTP/
1.1" 200 112739 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, lik
e Gecko) Chrome/26.0.1410.64 Safari/537.31"
::1 - - [08/May/2013:18:31:38 +0700] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.
15 (CentOS) (internal dummy connection)"
123.24.40.218 - - [08/May/2013:18:31:38 +0700] "GET /vbb8/clientscript/yui/conne
ction/connection-min.js?v=387 HTTP/1.1" 304 - "http://hocdan.com/vbb8/showthread
.php?p=177409" "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.
0"
123.24.40.218 - - [08/May/2013:18:31:38 +0700] "GET /vbb8/clientscript/vbulletin
_global.js?v=387 HTTP/1.1" 304 - "http://hocdan.com/vbb8/showthread.php?p=177409
" "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0"
[root@localhost ~]#


Đây là một đoạn access_log của apache ( log chung nhiều site ) . Nhìn qua thì mình không thấy có gì bất thường. Mình dùng real time của google analytics để xem số lượng user online trên website cũng không thấy tăng đột biến, nhưng CPU mà mysql sử dụng thì lại tăng chóng mặt.
[Up] [Print Copy]
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 08/05/2013 22:04:00 (+0700) | #5 | 275581
thanhtamntp
Member

[Minus]    0    [Plus]
Joined: 08/12/2008 10:50:06
Messages: 247
Offline
[Profile] [PM]
Em cũng giống bác, từ 2 tuần nay server nó thường xuyên bị overload. Optimize mãi mà vẫn không về 1 được. 2 ngày này nó chạy Load Averages 10-20 là tốt lắm rồi smilie
[Up] [Print Copy]
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 08/05/2013 22:13:11 (+0700) | #6 | 275582
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]
- Bạn thử chạy lại mấy câu truy vấn kia nhưng thêm `EXPLAIN` vào trước xem nó bảo sao
- Cài Percona Toolkit lên, rồi chạy `pt-query-digest /var/log/mysqldslow.log` và gửi kết quả lên
- File cấu hình quá sơ sài. Nên down quyển "bí kíp" này về mà luyện: http://www.amazon.com/High-Performance-MySQL-Optimization-Replication/dp/1449314287
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 09/05/2013 08:08:35 (+0700) | #7 | 275596
dungnguyen31
Member

[Minus]    0    [Plus]
Joined: 27/07/2007 11:29:48
Messages: 7
Offline
[Profile] [PM]

quanta wrote:
- Bạn thử chạy lại mấy câu truy vấn kia nhưng thêm `EXPLAIN` vào trước xem nó bảo sao
- Cài Percona Toolkit lên, rồi chạy `pt-query-digest /var/log/mysqldslow.log` và gửi kết quả lên
- File cấu hình quá sơ sài. Nên down quyển "bí kíp" này về mà luyện: http://www.amazon.com/High-Performance-MySQL-Optimization-Replication/dp/1449314287 


Chạy
Code:
pt-query-digest /var/log/mysqldslow.log


Code:
/home/user/public_html$ pt-query-digest /var/log/mysqldslow.log

# 140ms user time, 0 system time, 21.20M rss, 78.15M vsz
# Current date: Thu May  9 08:56:35 2013
# Hostname: localhost.localdomain
# Files: /var/log/mysqldslow.log
# Overall: 19 total, 3 unique, 0.00 QPS, 0.00x concurrency _______________
# Time range: 2013-05-07 17:08:16 to 2013-05-09 04:04:26
# Attribute          total     min     max     avg     95%  stddev  median
# ============     ======= ======= ======= ======= ======= ======= =======
# Exec time           219s      3s     31s     12s     29s      8s      8s
# Lock time          558us    10us   199us    29us   144us    49us    10us
# Rows sent         10.19M       0   2.42M 548.98k   1.86M 715.62k 192.13k
# Rows examine      12.33M  52.67k   2.42M 664.35k   1.86M 715.56k 212.08k
# Query size         2.99k      45   1.75k  161.05  363.48  378.02   51.63

# Profile
# Rank Query ID           Response time  Calls R/Call  V/M   Item
# ==== ================== ============== ===== ======= ===== =============
#    1 0x67A347A2812914DF 185.4841 84.8%    17 10.9108  6.05 SELECT hd_log_errors
#    2 0xC15DD7368A5CF191  22.0756 10.1%     1 22.0756  0.00 SELECT table_mem_group table_mem_group_activities table_mem_ref_group user usertextfield userfield avatar customavatar table_user
#    3 0x26EBB66E01ACC908  11.0738  5.1%     1 11.0738  0.00 SELECT table_mem_group_activities table_user_notification table_mem_group

# Query 1: 0.08 QPS, 0.85x concurrency, ID 0x67A347A2812914DF at byte 2535
# This item is included in the report because it matches --limit.
# Scores: V/M = 6.05
# Time range: 2013-05-09 04:00:49 to 04:04:26
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         89      17
# Exec time     84    185s      3s     31s     11s     29s      8s      8s
# Lock time     37   207us    10us    24us    12us    13us     3us    10us
# Rows sent     99  10.19M  52.67k   2.42M 613.57k   1.86M 731.21k 192.13k
# Rows examine  82  10.19M  52.67k   2.42M 613.57k   1.86M 731.21k 192.13k
# Query size    29     888      45      64   52.24   59.77    5.16   51.63
# String:
# Databases    hd_forum (5/29%), hd_media (3/17%)... 4 more
# Hosts        localhost
# Users        root
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms
#  10ms
# 100ms
#    1s  ################################################################
#  10s+  ##################################
# Tables
#    SHOW TABLE STATUS FROM `hd_forum` LIKE 'hd_log_errors'\G
#    SHOW CREATE TABLE `hd_forum`.`hd_log_errors`\G
SELECT /*!40001 SQL_NO_CACHE */ * FROM `hd_log_errors`\G
# Converted for EXPLAIN
# EXPLAIN /*!50100 PARTITIONS*/
SELECT /*!40001 SQL_NO_CACHE */ * FROM `hd_log_errors`\G

# Query 2: 0 QPS, 0x concurrency, ID 0xC15DD7368A5CF191 at byte 557 ______
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2013-05-07 17:09:07
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          5       1
# Exec time     10     22s     22s     22s     22s     22s       0     22s
# Lock time     35   199us   199us   199us   199us   199us       0   199us
# Rows sent      0      10      10      10      10      10       0      10
# Rows examine   5 705.73k 705.73k 705.73k 705.73k 705.73k       0 705.73k
# Query size    58   1.75k   1.75k   1.75k   1.75k   1.75k       0   1.75k
# String:
# Hosts        localhost
# Users        hd_music
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms
#  10ms
# 100ms
#    1s
#  10s+  ################################################################
# Tables
#    SHOW TABLE STATUS LIKE 'table_mem_group'\G
#    SHOW CREATE TABLE `table_mem_group`\G
#    SHOW TABLE STATUS LIKE 'table_mem_group_activities'\G
#    SHOW CREATE TABLE `table_mem_group_activities`\G
#    SHOW TABLE STATUS LIKE 'table_mem_ref_group'\G
#    SHOW CREATE TABLE `table_mem_ref_group`\G
#    SHOW TABLE STATUS LIKE 'user'\G
#    SHOW CREATE TABLE `user`\G
#    SHOW TABLE STATUS LIKE 'usertextfield'\G
#    SHOW CREATE TABLE `usertextfield`\G
#    SHOW TABLE STATUS LIKE 'userfield'\G
#    SHOW CREATE TABLE `userfield`\G
#    SHOW TABLE STATUS LIKE 'avatar'\G
#    SHOW CREATE TABLE `avatar`\G
#    SHOW TABLE STATUS LIKE 'customavatar'\G
#    SHOW CREATE TABLE `customavatar`\G
#    SHOW TABLE STATUS LIKE 'table_user'\G
#    SHOW CREATE TABLE `table_user`\G
# EXPLAIN /*!50100 PARTITIONS*/
SELECT DISTINCT mg.group_id, mg.group_name, mg.group_code, mg.group_logo, rs.tongtv AS tongtv
				FROM table_mem_group AS mg
				INNER JOIN (select ac_groupid,is_newest from table_mem_group_activities order by is_newest DESC) AS mga ON mga.ac_groupid = mg.group_id  
				INNER JOIN (select DISTINCT group_id, count(member_id) AS tongtv FROM table_mem_ref_group WHERE `status`=2 GROUP BY group_id) AS rs ON rs.group_id = mg.group_id AND mg.filter !=8
				ORDER BY mga.is_newest DESC LIMIT 0,10;



# Time: 130507 19:31:40
# User@Host: root[root] @ localhost []
# Query_time: 16.609280  Lock_time: 0.003681 Rows_sent: 30  Rows_examined: 877922
use vbbed;
SET timestamp=1367929900;
SELECT user.*,usertextfield.*,userfield.*, user.userid, options,
			IF(user.displaygroupid=0, user.usergroupid, user.displaygroupid) AS displaygroupid, infractiongroupid
		
		,avatar.avatarpath,NOT ISNULL(customavatar.userid) AS hascustomavatar,customavatar.dateline AS avatardateline, customavatar.width AS avwidth, customavatar.height AS avheight
		
		 , IF((options & 512 AND user.userid <> 0), 0, lastactivity) AS lastvisittime 
		
		
		
		FROM user AS user
		LEFT JOIN usertextfield AS usertextfield ON(usertextfield.userid=user.userid)
		LEFT JOIN userfield AS userfield ON(userfield.userid=user.userid)
		
		LEFT JOIN avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN customavatar AS customavatar ON(customavatar.userid = user.userid)
		
		
		
		WHERE 1=1
			AND (user.usergroupid IN (-1,6,7,2,5))
			
		ORDER BY user.posts desc 
		LIMIT 214650, 30;# Time: 130509  4:00:16
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 3.709931  Lock_time: 0.000011 Rows_sent: 149408  Rows_examined: 149408
use hd_amthuc;
SET timestamp=1368046816;
SELECT /*!40001 SQL_NO_CACHE */ * FROM `table_user`\G

# Query 3: 0 QPS, 0x concurrency, ID 0x26EBB66E01ACC908 at byte 0 ________
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2013-05-07 17:08:16
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          5       1
# Exec time      5     11s     11s     11s     11s     11s       0     11s
# Lock time     27   152us   152us   152us   152us   152us       0   152us
# Rows sent      0       0       0       0       0       0       0       0
# Rows examine  11   1.45M   1.45M   1.45M   1.45M   1.45M       0   1.45M
# Query size    12     375     375     375     375     375       0     375
# String:
# Hosts        localhost
# Users        hd_music
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms
#  10ms
# 100ms
#    1s
#  10s+  ################################################################
# Tables
#    SHOW TABLE STATUS LIKE 'table_mem_group_activities'\G
#    SHOW CREATE TABLE `table_mem_group_activities`\G
#    SHOW TABLE STATUS LIKE 'table_user_notification'\G
#    SHOW CREATE TABLE `table_user_notification`\G
#    SHOW TABLE STATUS LIKE 'table_mem_group'\G
#    SHOW CREATE TABLE `table_mem_group`\G
# EXPLAIN /*!50100 PARTITIONS*/
SELECT un.un_id, gc.ac_id,gc.ac_groupid,gc.ac_content,g.group_code,g.group_name
				FROM table_mem_group_activities AS gc 
				INNER JOIN table_user_notification AS un ON un.un_itemid = gc.ac_id
				INNER JOIN table_mem_group AS g ON g.group_id = gc.ac_groupid 
				WHERE un_ownerid='54741' AND gc.is_newnotify = 1 AND  un.is_newnotify = 1
				ORDER BY un.un_id ASC LIMIT 0,1\G


Thêm 'EXPLAIN' vào query.



Hiện tại em đã dùng .htaccess wwwect toàn bộ các request đến website không có nguồn refer tin cậy về một file php có nội dung :

Code:
<? 
$text=$_SERVER['QUERY_STRING']; 
$text = preg_replace("#php&#si",'php?',$text); 
echo('<title>Redirect to Main Contents</title><center><br><br>');
echo('<center><a href=http://mydomain.com'.$text.'>[Click vào đây]</a><br>để tiếp tục.</center>');

?>


thì ngay lập tức, load của mysqld giảm xuống, và tình trạng server trở về như sau :



Em nghĩ là do có lượng lớn request đến apache, apache gọi đến mysqld như một truy cập bình thường => lượng lớn request gây ra tình trạng mysqld sử dụng quá nhiều CPU và query chậm. Tuy nhiên đọc access_log thì không thấy vấn đề gì.

Về lâu dài, nếu cứ wwwect các request về 1 file php như vậy sẽ ảnh hưởng đến crawler. Nhờ mọi người góp ý.

[Up] [Print Copy]
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 09/05/2013 09:22:07 (+0700) | #8 | 275600
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]
- Ai đang SELECT * FROM `hd_log_errors`\G?
- Tìm hiểu ý nghĩa các cột của EXPLAIN (đặc biệt là possible_keys, key, rows)
- Chạy `SHOW KEYS FROM tbl_name` và tìm hiểu thêm về Indexes: http://dev.mysql.com/doc/refman/5.5/en/mysql-indexes.html
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Mysql tự nhiên ngốn CPU, Apache vượt max client allowed 14/05/2013 10:43:01 (+0700) | #9 | 275697
phuongtnotv
Member

[Minus]    0    [Plus]
Joined: 04/04/2013 02:40:50
Messages: 17
Offline
[Profile] [PM]

quanta wrote:
- Ai đang SELECT * FROM `hd_log_errors`\G?
- Tìm hiểu ý nghĩa các cột của EXPLAIN (đặc biệt là possible_keys, key, rows)
- Chạy `SHOW KEYS FROM tbl_name` và tìm hiểu thêm về Indexes: http://dev.mysql.com/doc/refman/5.5/en/mysql-indexes.html 


Mình cũng bị tình trạng thế này

mysql và php-fpm lúc nào cũng chiếm CPU trên 100%


[Up] [Print Copy]
[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to: 
 Users currently in here 
1 Anonymous

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|