1

i have created a smart interface WP based which we use to manage clients..
it uses a lot of information and data each time a client is returned / viewed.

it is a locked interface and does not have traffic spikes

in the past month i have seen major memory and CPU usage spikes so,
i have installed the debug bar and opended all the options.

What i am seeing is that each time wordpress includes wp-header-blog
and template-loader (or am i wrong?) - can i declare those once?

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?
can i "Declare" them once to minimize memory usage and load time?

am i completlty missing the point and can you share some tips to downsize
the CPU usage & memory usage if its a given i cant use caching plugin.

  • I don't understand the question. What does a query have to do with spike in memory and CPU usage? – Mark Kaplun Apr 4 '14 at 6:46
  • i admit i am lacking in that area... but as i have read across multiple blogs / articles each query and especially when we are talking about 500+ chokes the memory and cpu usage since its tasking the server to retrieve data and holds it before displaying it in the memory. i would love some information to correct my view / teach me more (searched!) - the same as plugins create additional resources use so does queries. – Sagive SEO Apr 4 '14 at 7:22
  • In general a long query might cause a cpu/mem usage spike but that is only for the duration of the generation of the specific page. If you see spikes via monitoring tools it means that the problem continues for at least several minutes. If the site usage pattern haven't changed during the spikes then the most logical explanation is that the site has more visitors but if the spikes correlate with usage changes then maybe yu have to optimize the specific pages that are slow, which means that you have to identify them first.... – Mark Kaplun Apr 4 '14 at 8:59
  • thanks mate, i have optimized the pages in all other regards aka images, minify, minimizing the code and other stuff... The only thing i have left is to minize un-neccesery queries - the uppercode is a print-out of the debug toolbar plugin... i was wondering if the wp-blog-header.php and template-loader.php is actually loading time after time and how to prevent it. – Sagive SEO Apr 4 '14 at 22:14
  • yes they are loading on each page generation. Best way to prevent them from loading is to use caching ;) – Mark Kaplun Apr 5 '14 at 4:57
1

Sagive,

  1. wp-blog-header.php loaded in the index.php on each page request. AJAX calls included (if that's what you mean "time after time". Then it loads template-loader.php.
  2. This has nothing to do with the SQLs you see, and not with the "spikes".
  3. Install the Query Monitor plugin to see your SQLs better in the Debug Bar.
  4. Do not publish sensitive information here (like the name of your client in the first SQL). :-)
| improve this answer | |
  • thanks ;) - this is an output from my localhost so.. the path's are different. - i am wondering how to call these files only once. even if i have 20 ajax files loading into the same page? – Sagive SEO Apr 12 '14 at 21:47
  • p.s thanks for stopping by gregory, i am following you on g+ and got your site bookmarked ;) – Sagive SEO Apr 13 '14 at 10:01
  • Altough not a solution - pointing out that each ajax file (and i created a lot to keep things organized) loads wp-blog-header & template-loader - is a direction to minimize the ajax files into as few as possible which is helpfull - thanks again ;) – Sagive SEO Apr 16 '14 at 21:58
1

HTTP is a stateless protocol and it will initialize the whole WordPress system each time a request hits any page in the server. Scripts like wp-blog-header.php, template-loader etc are required to properly initialize WordPress.

| improve this answer | |
  • so... it cant be done? i cant load those files for each ajax file and each query? i am missing some information... why does it seem that WP requires those files on each query? – Sagive SEO Apr 13 '14 at 10:04
  • These are not each query.. rather each request to server( be it AJAX too) will need these files. – Subharanjan Apr 13 '14 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.