High CPU usage on server by MySQL on AWS ubuntu server
up vote
-1
down vote
favorite
MySQL showing very high CPU usage. like over 200% sometime.
I had slow query log on. and slow query time set to 1s.
there is not any slow query.
I am using code igniter PHP.
my my.cnf file :
[mysqld]
innodb_io_capacity=2000
innodb_read_io_threads=32
innodb_write_io_threads=32
innodb_log_buffer_size=250M
innodb_thread_concurrency=0
innodb_buffer_pool_size=1000M
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
##
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#
# * Fine Tuning
#
innodb_buffer_pool_size = 12G
key_buffer_size = 1G
max_allowed_packet = 256M
thread_stack = 192K
thread_cache_size = 100
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = BACKUP
max_connections = 300
#innodb_buffer_pool_instances=8
#innodb_read_io_threads=8
#innodb_write_io_threads=8
#open_files_limit = 1024
#table_open_cache = 400
server_id = 2
bind-address = 0.0.0.0
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1
auto-increment-increment = 2
auto-increment-offset = 2
replicate-ignore-db=phpmyadmin
replicate-ignore-db=mysql
skip-name-resolve
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit=0
query_cache_size=0
sort_buffer_size = 2M
join_buffer_size = 128K
read_buffer_size = 128K
read_rnd_buffer_size=256K
what can I do to reduce CPU usage?
Is there any way to find which queryes are causing high cpu usage o
php mysql amazon-ec2 codeigniter-3
add a comment |
up vote
-1
down vote
favorite
MySQL showing very high CPU usage. like over 200% sometime.
I had slow query log on. and slow query time set to 1s.
there is not any slow query.
I am using code igniter PHP.
my my.cnf file :
[mysqld]
innodb_io_capacity=2000
innodb_read_io_threads=32
innodb_write_io_threads=32
innodb_log_buffer_size=250M
innodb_thread_concurrency=0
innodb_buffer_pool_size=1000M
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
##
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#
# * Fine Tuning
#
innodb_buffer_pool_size = 12G
key_buffer_size = 1G
max_allowed_packet = 256M
thread_stack = 192K
thread_cache_size = 100
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = BACKUP
max_connections = 300
#innodb_buffer_pool_instances=8
#innodb_read_io_threads=8
#innodb_write_io_threads=8
#open_files_limit = 1024
#table_open_cache = 400
server_id = 2
bind-address = 0.0.0.0
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1
auto-increment-increment = 2
auto-increment-offset = 2
replicate-ignore-db=phpmyadmin
replicate-ignore-db=mysql
skip-name-resolve
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit=0
query_cache_size=0
sort_buffer_size = 2M
join_buffer_size = 128K
read_buffer_size = 128K
read_rnd_buffer_size=256K
what can I do to reduce CPU usage?
Is there any way to find which queryes are causing high cpu usage o
php mysql amazon-ec2 codeigniter-3
Are the PHP & CI tags relevant?
– Nigel Ren
2 days ago
I do not know if something on CI side may causing this or not I try everything I can find on internet on MySQL site so I think may be someone with good knowledge of CI may help me if they had faced this issue before
– Desi Mulga
2 days ago
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
MySQL showing very high CPU usage. like over 200% sometime.
I had slow query log on. and slow query time set to 1s.
there is not any slow query.
I am using code igniter PHP.
my my.cnf file :
[mysqld]
innodb_io_capacity=2000
innodb_read_io_threads=32
innodb_write_io_threads=32
innodb_log_buffer_size=250M
innodb_thread_concurrency=0
innodb_buffer_pool_size=1000M
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
##
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#
# * Fine Tuning
#
innodb_buffer_pool_size = 12G
key_buffer_size = 1G
max_allowed_packet = 256M
thread_stack = 192K
thread_cache_size = 100
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = BACKUP
max_connections = 300
#innodb_buffer_pool_instances=8
#innodb_read_io_threads=8
#innodb_write_io_threads=8
#open_files_limit = 1024
#table_open_cache = 400
server_id = 2
bind-address = 0.0.0.0
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1
auto-increment-increment = 2
auto-increment-offset = 2
replicate-ignore-db=phpmyadmin
replicate-ignore-db=mysql
skip-name-resolve
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit=0
query_cache_size=0
sort_buffer_size = 2M
join_buffer_size = 128K
read_buffer_size = 128K
read_rnd_buffer_size=256K
what can I do to reduce CPU usage?
Is there any way to find which queryes are causing high cpu usage o
php mysql amazon-ec2 codeigniter-3
MySQL showing very high CPU usage. like over 200% sometime.
I had slow query log on. and slow query time set to 1s.
there is not any slow query.
I am using code igniter PHP.
my my.cnf file :
[mysqld]
innodb_io_capacity=2000
innodb_read_io_threads=32
innodb_write_io_threads=32
innodb_log_buffer_size=250M
innodb_thread_concurrency=0
innodb_buffer_pool_size=1000M
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
##
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#
# * Fine Tuning
#
innodb_buffer_pool_size = 12G
key_buffer_size = 1G
max_allowed_packet = 256M
thread_stack = 192K
thread_cache_size = 100
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = BACKUP
max_connections = 300
#innodb_buffer_pool_instances=8
#innodb_read_io_threads=8
#innodb_write_io_threads=8
#open_files_limit = 1024
#table_open_cache = 400
server_id = 2
bind-address = 0.0.0.0
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1
auto-increment-increment = 2
auto-increment-offset = 2
replicate-ignore-db=phpmyadmin
replicate-ignore-db=mysql
skip-name-resolve
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit=0
query_cache_size=0
sort_buffer_size = 2M
join_buffer_size = 128K
read_buffer_size = 128K
read_rnd_buffer_size=256K
what can I do to reduce CPU usage?
Is there any way to find which queryes are causing high cpu usage o
php mysql amazon-ec2 codeigniter-3
php mysql amazon-ec2 codeigniter-3
asked 2 days ago
Desi Mulga
237
237
Are the PHP & CI tags relevant?
– Nigel Ren
2 days ago
I do not know if something on CI side may causing this or not I try everything I can find on internet on MySQL site so I think may be someone with good knowledge of CI may help me if they had faced this issue before
– Desi Mulga
2 days ago
add a comment |
Are the PHP & CI tags relevant?
– Nigel Ren
2 days ago
I do not know if something on CI side may causing this or not I try everything I can find on internet on MySQL site so I think may be someone with good knowledge of CI may help me if they had faced this issue before
– Desi Mulga
2 days ago
Are the PHP & CI tags relevant?
– Nigel Ren
2 days ago
Are the PHP & CI tags relevant?
– Nigel Ren
2 days ago
I do not know if something on CI side may causing this or not I try everything I can find on internet on MySQL site so I think may be someone with good knowledge of CI may help me if they had faced this issue before
– Desi Mulga
2 days ago
I do not know if something on CI side may causing this or not I try everything I can find on internet on MySQL site so I think may be someone with good knowledge of CI may help me if they had faced this issue before
– Desi Mulga
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
there is not any slow query
There aren't any slow queries, or there aren't any slow queries showing in the log? I think your first prt of call would be to check if the query logging is working as you expect. This can be done easily using discretionary locks without adding additional load on the system.
Assuming that there really are no queries taking over 1 second, then the load arises fro lots of queries taking less than 1 second. You need to capture them all to identify and prioritize your tuning efforts. But you might start by enabling the query cache (which you have disabled for some reason).
yes I am sure that slow query log is working.
– Desi Mulga
2 days ago
I test it by running SELECT SLEEP(2); and that query is logged in
– Desi Mulga
2 days ago
yes you were right. there is one function in my PHP for loop code which firing query. so if there are 1000 players active this loop fires same query 1000 times. i convert my code and now no query runs in for loop and now my sql cpu usage is under 5%
– Desi Mulga
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
there is not any slow query
There aren't any slow queries, or there aren't any slow queries showing in the log? I think your first prt of call would be to check if the query logging is working as you expect. This can be done easily using discretionary locks without adding additional load on the system.
Assuming that there really are no queries taking over 1 second, then the load arises fro lots of queries taking less than 1 second. You need to capture them all to identify and prioritize your tuning efforts. But you might start by enabling the query cache (which you have disabled for some reason).
yes I am sure that slow query log is working.
– Desi Mulga
2 days ago
I test it by running SELECT SLEEP(2); and that query is logged in
– Desi Mulga
2 days ago
yes you were right. there is one function in my PHP for loop code which firing query. so if there are 1000 players active this loop fires same query 1000 times. i convert my code and now no query runs in for loop and now my sql cpu usage is under 5%
– Desi Mulga
2 days ago
add a comment |
up vote
0
down vote
accepted
there is not any slow query
There aren't any slow queries, or there aren't any slow queries showing in the log? I think your first prt of call would be to check if the query logging is working as you expect. This can be done easily using discretionary locks without adding additional load on the system.
Assuming that there really are no queries taking over 1 second, then the load arises fro lots of queries taking less than 1 second. You need to capture them all to identify and prioritize your tuning efforts. But you might start by enabling the query cache (which you have disabled for some reason).
yes I am sure that slow query log is working.
– Desi Mulga
2 days ago
I test it by running SELECT SLEEP(2); and that query is logged in
– Desi Mulga
2 days ago
yes you were right. there is one function in my PHP for loop code which firing query. so if there are 1000 players active this loop fires same query 1000 times. i convert my code and now no query runs in for loop and now my sql cpu usage is under 5%
– Desi Mulga
2 days ago
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
there is not any slow query
There aren't any slow queries, or there aren't any slow queries showing in the log? I think your first prt of call would be to check if the query logging is working as you expect. This can be done easily using discretionary locks without adding additional load on the system.
Assuming that there really are no queries taking over 1 second, then the load arises fro lots of queries taking less than 1 second. You need to capture them all to identify and prioritize your tuning efforts. But you might start by enabling the query cache (which you have disabled for some reason).
there is not any slow query
There aren't any slow queries, or there aren't any slow queries showing in the log? I think your first prt of call would be to check if the query logging is working as you expect. This can be done easily using discretionary locks without adding additional load on the system.
Assuming that there really are no queries taking over 1 second, then the load arises fro lots of queries taking less than 1 second. You need to capture them all to identify and prioritize your tuning efforts. But you might start by enabling the query cache (which you have disabled for some reason).
edited 2 days ago
answered 2 days ago
symcbean
40.6k43976
40.6k43976
yes I am sure that slow query log is working.
– Desi Mulga
2 days ago
I test it by running SELECT SLEEP(2); and that query is logged in
– Desi Mulga
2 days ago
yes you were right. there is one function in my PHP for loop code which firing query. so if there are 1000 players active this loop fires same query 1000 times. i convert my code and now no query runs in for loop and now my sql cpu usage is under 5%
– Desi Mulga
2 days ago
add a comment |
yes I am sure that slow query log is working.
– Desi Mulga
2 days ago
I test it by running SELECT SLEEP(2); and that query is logged in
– Desi Mulga
2 days ago
yes you were right. there is one function in my PHP for loop code which firing query. so if there are 1000 players active this loop fires same query 1000 times. i convert my code and now no query runs in for loop and now my sql cpu usage is under 5%
– Desi Mulga
2 days ago
yes I am sure that slow query log is working.
– Desi Mulga
2 days ago
yes I am sure that slow query log is working.
– Desi Mulga
2 days ago
I test it by running SELECT SLEEP(2); and that query is logged in
– Desi Mulga
2 days ago
I test it by running SELECT SLEEP(2); and that query is logged in
– Desi Mulga
2 days ago
yes you were right. there is one function in my PHP for loop code which firing query. so if there are 1000 players active this loop fires same query 1000 times. i convert my code and now no query runs in for loop and now my sql cpu usage is under 5%
– Desi Mulga
2 days ago
yes you were right. there is one function in my PHP for loop code which firing query. so if there are 1000 players active this loop fires same query 1000 times. i convert my code and now no query runs in for loop and now my sql cpu usage is under 5%
– Desi Mulga
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372786%2fhigh-cpu-usage-on-server-by-mysql-on-aws-ubuntu-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are the PHP & CI tags relevant?
– Nigel Ren
2 days ago
I do not know if something on CI side may causing this or not I try everything I can find on internet on MySQL site so I think may be someone with good knowledge of CI may help me if they had faced this issue before
– Desi Mulga
2 days ago