我有一个非常大的网站,它是用PHP和MYSQL建立起来的。
在我的网站上,在不同的PHP页面上,我有超过1000个不同的查询,很难将它们全部更新到MYSQLI。
我用4GB内存购买了VPS服务器,在过去的几个月里,我经历了非常缓慢的页面加载。
当我重新启动服务器时,一切都运行得很顺利,但是几个小时/天之后,网站的速度越来越慢,因为加载页面的时间是3+秒。我注意到mysqld服务的内存使用量正在增加,从服务器重新启动的80 of增加到大约400 of甚至更多。
我将index.php mysql_close()放在末尾,但是连接数似乎还在增加。
问,什么会导致mysql内存使用量的无限增加?将我的所有查询更新到MYSQLI可以提高性能吗?
一些资料:
innodb_version
5.5.31
protocol_version
10
slave_type_conversions
version
5.5.31-log
version_comment
MySQL Community Server (GPL)
version_compile_machine
x86_64
version_compile_os
Linux存储引擎:混合(有些表是INNODB,有些表是MyISAM。my.cnf:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
max-connections=100000
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
thread_cache_size=5
table_open_cache=99390
sort_buffer_size=512M
read_rnd_buffer_size=512M
query_cache_size=512M
query_cache_limit = 16M
query_cache_type = 1
slow_query_log=1
slow_query_log_file=slow_query_log.log #
long_query_time=5
log-queries-not-using-indexes=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid当我使用show processlist时,大约有6-7个查询在运行。
发布于 2016-09-23 03:52:17
max-connections=100000 --好极了!降至1000
table_open_cache=99390 --下降到,比方说,2000年
sort_buffer_size=512M --下降到内存的1%,比如说,4000万。
read_rnd_buffer_size=512M --同上
query_cache_size=512M --太大了;减慢速度;降到40米
long_query_time=5
log-queries-not-using-indexes=1 --在没有提供太多信息的情况下对慢速日志进行混乱;更改为0。
你没有说你用的是哪个引擎。有关MyISAM和InnoDB的建议,请阅读MyISAM。
1000页--还不算太多。
哪个网络服务器?如果是Apache,请不要将MaxClients设置为20以上。
2022 postscript:query_cache_size和query_cache_type变量是从mySQL 8.0.3+中删除。
https://stackoverflow.com/questions/39596932
复制相似问题