降低WordPress中的CPU和数据库使用率

时间:2014-04-04 作者:Sagive

我创建了一个基于WP的智能界面,用于管理客户端
每次返回/查看客户端时,它都会使用大量信息和数据。

it is a locked interface and does not have traffic spikes

在过去的一个月里,我看到了内存和CPU使用率的大幅飙升,因此,我安装了调试栏并打开了所有选项。

我所看到的是,每次wordpress都包括wp header博客和模板加载器(或者我错了?)-我可以申报一下吗?

here is an example from the queries tab in the debug bar

\'clientsocialurls\'
require(\'wp-blog-header.php\'), require_once(\'wp-includes/template-loader.php\'), include(\'/themes/sagive-manager/category.php\'), include(\'/themes/sagive-manager/tabs/tab-siteinfo.php\'), get_page_by_title #47 (14.4ms)
SELECT ID FROM armnd_posts WHERE post_title = \'זמנהוף שירותי תרגום\' AND post_type= \'cheques\'

require(\'wp-blog-header.php\'), require_once(\'wp-includes/template-loader.php\'), include(\'/themes/sagive-manager/category.php\'), include(\'/themes/sagive-manager/tabs/tab-cheques.php\'), get_page_by_title #48 (3.9ms)
SELECT armnd_posts.* FROM armnd_posts WHERE 1=1 AND armnd_posts.post_type = \'attachments\' AND (armnd_posts.post_status = \'publish\') ORDER BY armnd_posts.post_date ASC 

require(\'wp-blog-header.php\'), require_once(\'wp-includes/template-loader.php\'), include(\'/themes/sagive-manager/category.php\'), include(\'/themes/sagive-manager/tabs/tab-attachments.php\'), get_posts, WP_Query->query, WP_Query->get_posts #49 (34.7ms)
SELECT post_id, meta_key, meta_value FROM armn_postmeta WHERE post_id IN (2073,2086,2093,2104,2109,2114,2119,2137,2143,2148,2154,2160,2165,2174,2178,2186,2274,2650,2708,3163,3356,3507,3644,3673,3893,3924,4039,4139,4286,4311,4515,4596,4666,4698,4722,4738,4740,4841,4860,4908,5219,5941,6086,6317) ORDER BY meta_id ASC

require(\'wp-blog-header.php\'), require_once(\'wp-includes/template-loader.php\'), include(\'/themes/sagive-manager/category.php\'), include(\'/themes/sagive-manager/tabs/tab-attachments.php\'), get_posts, WP_Query->query, WP_Query->get_posts, update_post_caches, update_postmeta_cache, update_meta_cache #50 (9.9ms)
SELECT armnd_posts.* FROM armnd_posts WHERE 1=1 AND armnd_posts.post_parent = 2119 AND armnd_posts.post_type = \'attachment\' AND (armnd_posts.post_status = \'inherit\') ORDER BY armnd_posts.post_date DESC 

require(\'wp-blog-header.php\'), require_once(\'wp-includes/template-loader.php\'), include(\'/themes/sagive-manager/category.php\'), include(\'/themes/sagive-manager/tabs/tab-attachments.php\'), get_posts, WP_Query->query, WP_Query->get_posts
does this means wordpress loads both files each time a query is called?
我是否可以“声明”它们一次,以最大限度地减少内存使用和加载时间?

我完全没有抓住要点,你能分享一些降低CPU使用率的技巧吗;内存使用率,如果它是一个给定的我不能使用缓存插件。

2 个回复
最合适的回答,由SO网友:tivnet 整理而成

萨吉夫,

  1. wp-blog-header.php 加载到index.php 在每个页面上请求。包括AJAX调用(如果这是“一次又一次”的意思),然后加载template-loader.php.请勿在此处发布敏感信息(如第一条SQL中的客户端名称)。:-)

SO网友:Subharanjan

HTTP是一种无状态协议,每次请求到达服务器中的任何页面时,它都会初始化整个WordPress系统。像wp blog header这样的脚本。正确初始化WordPress需要php、模板加载器等。

结束

相关推荐

Fatal error: Out of memory

我在下一个工程师尝试创建缩略图时出现了内存问题。Wp版本为3.4.1致命错误:/xxx/wp-content/plugins/nextgen-gallery/lib/gd中内存不足(已分配29884416)(尝试分配2000字节)。缩略图。股份有限公司phpon线179但我的记忆没有超出:PHP Version : 5.2.17 / 32Bit OS Memory limit : 128 MByte Memory usage : 27.75 MByte我正不顾一切地试图解决这个问题。乔,非