我有一台 Windows 7 服务器,刚刚安装了 mysql。
一段时间后,我将在本地网络上连接到它,但服务器响应缓慢,无法正确回答请求。
我的客户每秒最多有 3k-4k 个请求
该服务器有两个 xeon cpu,64gb ram 和一些 10k sas 硬盘
但 CPU 使用率低于 10%,RAM 使用率约为 2 GB
我的mysql配置如下:
[client]
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_connection=5000
max_allowed_packet = 10M
table_open_cache = 512
sort_buffer_size = 20M
read_buffer_size = 20M
read_rnd_buffer_size = 80M
myisam_sort_buffer_size = 64M
thread_cache_size = 16
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
log-bin=mysql-bin
server-id = 1
innodb_flush_method = O_DIRECT
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
我怎样才能获得更好的表现?
答案1
您的表格使用什么引擎?应该是 InnoDB。在这种情况下,您应该配置
innodb_buffer_pool_size = 20G
(或者可能更多;您有多少数据?)
使用slowlog找出慢查询,然后我们再SHOW CREATE TABLE
看看EXPLAIN SELECT ...
。