我客户的服务器最近开始出现性能问题。服务器上托管的单个网站加载速度非常慢。它是使用自定义主题通过 WordPress 构建的。安装了最少量的插件,并且在出现性能问题的最近几周内没有添加任何插件。
该服务器有 2 个 CPU 和 2GB 内存。服务器堆栈是 LAMP,带有 Ubuntu 20.04 和 PHP FPM。所有安装的软件都保持最新。
运行 WordPress 网站时,两个 CPU 的使用率都持续超过 80%。
free -m 命令返回以下内容:总计 1983、已使用 1734、可用 64、共享 132、Buff/Cache 184 和可用 12。
重新启动服务器可以暂时解决这些问题。
安装了 Redis 服务器用于对象缓存。目前服务器或 WordPress 中未安装其他缓存或优化插件。
我运行了sudo tail -n 10 /var/log/apache2/domain.com_error.log
并包含下面的输出。
[Mon Feb 20 09:59:27.377362 2023] [proxy_fcgi:error] [pid 310468] [client 104.224.117.81:33410] AH01071: Got error 'PHP message: Predis\\Response\\ServerException: LOADING Redis is loading the dataset in memory in /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php:352\nStack trace:\n#0 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(320): Predis\\Client->onErrorResponse()\n#1 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(299): Predis\\Client->executeCommand()\n#2 /var/www/example.com/wp-content/object-cache.php(562): Predis\\Client->__call()\n#3 /var/www/example.com/wp-content/object-cache.php(257): WP_Object_Cache->__construct()\n#4 /var/www/example.com/wp-includes/load.php(730): wp_cache_init()\n#5 /var/www/example.com/wp-settings.php(131): wp_start_object_cache()\n#6 /var/www/example.com/wp-config.php(109): require_once('...')\n#7 /var/www/example.com/wp-load.php(50): require_once('...')\n#8 /var/www/example.com/wp-blog-header.php(13): require_once(...', referer: https://www.example.com/listing/the-tree-corral/
[Mon Feb 20 09:59:28.858978 2023] [proxy_fcgi:error] [pid 310553] [client 157.55.39.219:22656] AH01071: Got error 'PHP message: Predis\\Connection\\ConnectionException: Connection refused [tcp://127.0.0.1:6379] in /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/AbstractConnection.php:132\nStack trace:\n#0 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(109): Predis\\Connection\\AbstractConnection->onConnectionError()\n#1 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(154): Predis\\Connection\\StreamConnection->createStreamSocket()\n#2 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/StreamConnection.php(80): Predis\\Connection\\StreamConnection->tcpStreamInitializer()\n#3 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Connection/AbstractConnection.php(81): Predis\\Connection\\StreamConnection->createResource()\n#4 /var/www/example.com/wp-content...'
[Mon Feb 20 09:59:28.859372 2023] [proxy_fcgi:error] [pid 310553] [client 157.55.39.219:22656] AH01071: Got error 'PHP message: PHP Warning: Undefined variable $image in /var/www/example.com/wp-content/themes/themename/functions.php on line 548'
[Mon Feb 20 09:59:32.089611 2023] [proxy_fcgi:error] [pid 310501] [client 157.55.39.219:24128] AH01071: Got error 'PHP message: Predis\\Response\\ServerException: LOADING Redis is loading the dataset in memory in /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php:352\nStack trace:\n#0 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(320): Predis\\Client->onErrorResponse()\n#1 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(299): Predis\\Client->executeCommand()\n#2 /var/www/example.com/wp-content/object-cache.php(562): Predis\\Client->__call()\n#3 /var/www/example.com/wp-content/object-cache.php(257): WP_Object_Cache->__construct()\n#4 /var/www/example.com/wp-includes/load.php(730): wp_cache_init()\n#5 /var/www/example.com/wp-settings.php(131): wp_start_object_cache()\n#6 /var/www/example.com/wp-config.php(109): require_once('...')\n#7 /var/www/example.com/wp-load.php(50): require_once('...')\n#8 /var/www/example.com/wp-blog-header.php(13): require_once(...'
[Mon Feb 20 09:59:32.089919 2023] [proxy_fcgi:error] [pid 310501] [client 157.55.39.219:24128] AH01071: Got error 'PHP message: PHP Warning: Undefined variable $image in /var/www/example.com/wp-content/themes/themename/functions.php on line 548'
[Mon Feb 20 09:59:32.285842 2023] [proxy_fcgi:error] [pid 310279] [client 185.191.171.4:8256] AH01071: Got error 'PHP message: Predis\\Response\\ServerException: LOADING Redis is loading the dataset in memory in /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php:352\nStack trace:\n#0 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(320): Predis\\Client->onErrorResponse()\n#1 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(299): Predis\\Client->executeCommand()\n#2 /var/www/example.com/wp-content/object-cache.php(562): Predis\\Client->__call()\n#3 /var/www/example.com/wp-content/object-cache.php(257): WP_Object_Cache->__construct()\n#4 /var/www/example.com/wp-includes/load.php(730): wp_cache_init()\n#5 /var/www/example.com/wp-settings.php(131): wp_start_object_cache()\n#6 /var/www/example.com/wp-config.php(109): require_once('...')\n#7 /var/www/example.com/wp-load.php(50): require_once('...')\n#8 /var/www/example.com/wp-blog-header.php(13): require_once(...'
[Mon Feb 20 09:59:32.286079 2023] [proxy_fcgi:error] [pid 310279] [client 185.191.171.4:8256] AH01071: Got error 'PHP message: PHP Warning: Undefined variable $image in /var/www/example.com/wp-content/themes/themename/functions.php on line 548'
[Mon Feb 20 09:59:32.561144 2023] [proxy_fcgi:error] [pid 309940] [client 185.191.171.19:16376] AH01071: Got error 'PHP message: Predis\\Response\\ServerException: LOADING Redis is loading the dataset in memory in /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php:352\nStack trace:\n#0 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(320): Predis\\Client->onErrorResponse()\n#1 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(299): Predis\\Client->executeCommand()\n#2 /var/www/example.com/wp-content/object-cache.php(562): Predis\\Client->__call()\n#3 /var/www/example.com/wp-content/object-cache.php(257): WP_Object_Cache->__construct()\n#4 /var/www/example.com/wp-includes/load.php(730): wp_cache_init()\n#5 /var/www/example.com/wp-settings.php(131): wp_start_object_cache()\n#6 /var/www/example.com/wp-config.php(109): require_once('...')\n#7 /var/www/example.com/wp-load.php(50): require_once('...')\n#8 /var/www/example.com/wp-blog-header.php(13): require_once(...'
[Mon Feb 20 09:59:33.157553 2023] [proxy_fcgi:error] [pid 310553] [client 157.55.39.219:22656] AH01071: Got error 'PHP message: Predis\\Response\\ServerException: LOADING Redis is loading the dataset in memory in /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php:352\nStack trace:\n#0 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(320): Predis\\Client->onErrorResponse()\n#1 /var/www/example.com/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(299): Predis\\Client->executeCommand()\n#2 /var/www/example.com/wp-content/object-cache.php(562): Predis\\Client->__call()\n#3 /var/www/example.com/wp-content/object-cache.php(257): WP_Object_Cache->__construct()\n#4 /var/www/example.com/wp-includes/load.php(730): wp_cache_init()\n#5 /var/www/example.com/wp-settings.php(131): wp_start_object_cache()\n#6 /var/www/example.com/wp-config.php(109): require_once('...')\n#7 /var/www/example.com/wp-load.php(50): require_once('...')\n#8 /var/www/example.com/wp-blog-header.php(13): require_once(...'
[Mon Feb 20 09:59:33.157733 2023] [proxy_fcgi:error] [pid 310553] [client 157.55.39.219:22656] AH01071: Got error 'PHP message: PHP Warning: Undefined variable $image in /var/www/example.com/wp-content/themes/themename/functions.php on line 548'
关于如何解决这些问题有什么建议吗?
我是一名新手服务器管理员,但渴望学习。