简体   繁体   中英

PHP in combination with MySQL is extremely slow

I am currently experiencing slowness with one of my servers. It is running an apache2 server with PHP and MySQL. The MySQL server is hosted on the same machine as the webserver itself.

Whenever I request a PHP file containing MySQL queries the page needs approximately 24 seconds to show up. While requesting the page the CPU usage of apache2 goes up to 11% (!) which is very much in comparison to what it used to be a week ago.

Non-PHP files or PHP files without MySQL queries are showing up immediately.

What could be causing the problems with scripts containing MySQL queries? I was unable to find any useful information inside the apache error logs.

database queries take time to run, and each query involves opening up at least one file. file access is slow.

you can speed up the requests by running the database in RAM instead of from the hard-drive, but the real answer is probably to cache as much as you can so you're doing as little database querying as possible.

In mysql console

show full processlist;  <-- to show what are the current SQL

To check where is the log file:-

show variables like '%log%'; <-- to show mysql variables

When doing query benchmark / testing, always remember to turn off query cache, using :-

set session query_cache_type=off;

由于某些cms日志记录功能,您可以检查mysql数据库是否大于2GB(或4GB),并且超出文件大小限制。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM