Hi,
I'm wondering if my 100% CPU usage of my mysql server is caused by the 100% use of connections. And secondly if there are same ways to decrese the usage of connections. I have 2 servers with 2GB RAM in the first i have set mpm.conf to have max 600 connections on the second (dedicated to mysql only) my.cnf only 365. This is my my.cnf:
## MySQL 5.1 Configuration
##
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
# The MySQL server
[mysqld]
user = mysql
basedir = /mysql
datadir = /databases
bind-address = 10.17.80.28
port = 3306
socket = /tmp/mysql.sock
tmpdir = /tmp
slow_query_log = /databases/slowquery.log
long_query_time = 1
skip_external_locking
default-storage-engine = innodb
server-id = 1
character-set-server = utf8
# Capacity Limits
#thread_concurrency = 0
# max_connections = 250
max_connections = 420
max_allowed_packet = 24M
table_open_cache = 400
table_cache = 2000
# General
# query_cache_size = 16M
query_cache_size = 32M
# thread_cache_size = 128
thread_cache_size = 300
# MyISAM Engine Settings
# key_buffer = 100M
key_buffer = 256M
# myisam_sort_buffer_size = 32M
myisam_sort_buffer_size = 64M
# InnoDB Engine settings
innodb_data_home_dir = /databases
innodb_data_file_path = ibdata1:100M:autoextend
innodb_buffer_pool_size = 512M
innodb_additional_mem_pool_size = 30M
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 2
#innodb_doublewrite = 0
innodb_log_buffer_size = 32M
innodb_log_file_size = 512M
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
-----------------------------------------------
And this is the report of tuning-primer.sh
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.1.51 x86_64
Uptime = 0 days 2 hrs 1 min 50 sec
Avg. qps = 381
Total Questions = 2787895
Threads Connected = 17
Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service
SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 1.000000 sec.
You have 34764 out of 2788011 that take longer than 1.000000 sec. to complete
syntax error on line 1, teletype
./tuning-primer.sh: line 606: [: -gt: unary operator expected
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html
WORKER THREADS
Current thread_cache_size = 300
Current threads_cached = 287
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 420
Current threads_connected = 17
Historic max_used_connections = 421
The number of used connections is 100% of the configured maximum.
You should raise max_connections
INNODB STATUS
Current InnoDB index space = 87 M
Current InnoDB data space = 275 M
Current InnoDB buffer pool free = 41 %
Current innodb_buffer_pool_size = 512 M
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory
MEMORY USAGE
Max Memory Ever Allocated : 1.97 G
Configured Max Per-thread Buffers : 1.12 G
Configured Max Global Buffers : 862 M
Configured Max Memory Limit : 1.96 G
Physical Memory : 2.00 G
nMax memory limit exceeds 90% of physical memory
KEY BUFFER
No key reads?!
Seriously look into using some indexes
Current MyISAM index space = 98 K
Current key_buffer_size = 256 M
Key cache miss rate is 1 : 0
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine
QUERY CACHE
Query cache is enabled
Current query_cache_size = 32 M
Current query_cache_used = 4 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 14.43 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 132.00 K
You have had 0 queries where a join could not use an index properly
Your joins seem to be using indexes properly
OPEN FILES LIMIT
Current open_files_limit = 4430 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine
TABLE CACHE
Current table_open_cache = 2000 tables
Current table_definition_cache = 256 tables
You have a total of 53 tables
You have 1353 open tables.
The table_cache value seems to be fine
TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 16 M
Of 14078 temp tables, 6% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 95 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 0 : 2789568
Your table locking seems to be fine
----------------------
Thanks,
Marco
I'm wondering if my 100% CPU usage of my mysql server is caused by the 100% use of connections. And secondly if there are same ways to decrese the usage of connections. I have 2 servers with 2GB RAM in the first i have set mpm.conf to have max 600 connections on the second (dedicated to mysql only) my.cnf only 365. This is my my.cnf:
## MySQL 5.1 Configuration
##
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
# The MySQL server
[mysqld]
user = mysql
basedir = /mysql
datadir = /databases
bind-address = 10.17.80.28
port = 3306
socket = /tmp/mysql.sock
tmpdir = /tmp
slow_query_log = /databases/slowquery.log
long_query_time = 1
skip_external_locking
default-storage-engine = innodb
server-id = 1
character-set-server = utf8
# Capacity Limits
#thread_concurrency = 0
# max_connections = 250
max_connections = 420
max_allowed_packet = 24M
table_open_cache = 400
table_cache = 2000
# General
# query_cache_size = 16M
query_cache_size = 32M
# thread_cache_size = 128
thread_cache_size = 300
# MyISAM Engine Settings
# key_buffer = 100M
key_buffer = 256M
# myisam_sort_buffer_size = 32M
myisam_sort_buffer_size = 64M
# InnoDB Engine settings
innodb_data_home_dir = /databases
innodb_data_file_path = ibdata1:100M:autoextend
innodb_buffer_pool_size = 512M
innodb_additional_mem_pool_size = 30M
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 2
#innodb_doublewrite = 0
innodb_log_buffer_size = 32M
innodb_log_file_size = 512M
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
-----------------------------------------------
And this is the report of tuning-primer.sh
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.1.51 x86_64
Uptime = 0 days 2 hrs 1 min 50 sec
Avg. qps = 381
Total Questions = 2787895
Threads Connected = 17
Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service
SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 1.000000 sec.
You have 34764 out of 2788011 that take longer than 1.000000 sec. to complete
syntax error on line 1, teletype
./tuning-primer.sh: line 606: [: -gt: unary operator expected
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html
WORKER THREADS
Current thread_cache_size = 300
Current threads_cached = 287
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 420
Current threads_connected = 17
Historic max_used_connections = 421
The number of used connections is 100% of the configured maximum.
You should raise max_connections
INNODB STATUS
Current InnoDB index space = 87 M
Current InnoDB data space = 275 M
Current InnoDB buffer pool free = 41 %
Current innodb_buffer_pool_size = 512 M
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory
MEMORY USAGE
Max Memory Ever Allocated : 1.97 G
Configured Max Per-thread Buffers : 1.12 G
Configured Max Global Buffers : 862 M
Configured Max Memory Limit : 1.96 G
Physical Memory : 2.00 G
nMax memory limit exceeds 90% of physical memory
KEY BUFFER
No key reads?!
Seriously look into using some indexes
Current MyISAM index space = 98 K
Current key_buffer_size = 256 M
Key cache miss rate is 1 : 0
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine
QUERY CACHE
Query cache is enabled
Current query_cache_size = 32 M
Current query_cache_used = 4 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 14.43 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 132.00 K
You have had 0 queries where a join could not use an index properly
Your joins seem to be using indexes properly
OPEN FILES LIMIT
Current open_files_limit = 4430 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine
TABLE CACHE
Current table_open_cache = 2000 tables
Current table_definition_cache = 256 tables
You have a total of 53 tables
You have 1353 open tables.
The table_cache value seems to be fine
TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 16 M
Of 14078 temp tables, 6% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 95 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 0 : 2789568
Your table locking seems to be fine
----------------------
Thanks,
Marco