views:

32

answers:

0

I have moved my web application to a new server (nginx, mysql, php) with everything the latest version.

After that, I notice the application doesn't run very stable. Sometimes it is quick in response, sometimes very slow.

Then I look at the 'top', 'mysql-slow-log', and error log, here what I found out:

periodically, mysql-slow-log will tell me mysql_connect() is running slow (even on simple select query). Then it will bring down the php-fpm process, thus, generate mysql connection error.

My setting for php.ini is :
mysql.connect_timeout = 60
mysql.max_links = -1

and my.cnf is:

port            = 3306
socket          = /tmp/mysql.sock
skip-locking
key_buffer_size = 384M
max_allowed_packet = 16M
table_cache = 1024
sort_buffer_size = 32M
read_buffer_size = 32M
read_rnd_buffer_size = 32M
myisam_sort_buffer_size = 512M
thread_cache_size = 10
wait_timeout = 300
query_cache_size = 256M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 48
max_connections = 4000
innodb_file_per_table

connect_timeout = 10
log-slow-queries
long_query_time = 2

any idea what's going on? why mysql_connect() will get slow, and slow down periodically,... and then causing php die?

By the way, the Web App server is at different server from the DB server.