We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36782
    • 109 Posts
    Hi
    I've been hunting for days and am out of ideas.
    The site: http://electfletcher.com
    The issue: extremely slow php. w/ getResources. Remove getResources and the problem goes away. But getResources is integral to this site.
    I am calling it 3 times in each page; if I remove all but one, it goes away sort of...
    This one takes 0.08 seconds:
    [[!getCache? &element=`getResources` &cacheExpires=`14400` &parents=`2,48` &where=`{"id:!=":[[*id]]}` &showHidden=`1` &depth=`1` &hideContainers=`1`
     &tpl=`Agr.sidebar` &includeContent=`1` &sortby=`publishedon` &sortdir=`DESC` &tplFirst=`Agr.sidebar.left` &tplLast=`Agr.sidebar` &includeTVs=`1` &processTVs=`1`]]

    This one takes 1.8 seconds:
    [[!getCache? &element=`getResources` &cacheExpires=`1800` &parents=`[[*id]]` &showHidden=`1` &depth=`1` &hideContainers=`0` &where=`{"isfolder:=":1}` &tpl=`Agr.mainbar.recursive` &limit=`12` &includeContent=`1` &sortby=`publishedon` &sortdir=`DESC` &includeTVs=`1` &processTVs=`1`]]

    But this one, which only retrieves one result, takes 2 seconds:
    [[!getCache? &element=`getResources` &cacheExpires=`14400` &parents=`21` &showHidden=`1` &depth=`1` &limit=`1` &hideContainers=`1` &tpl=`Agr.endbar` &includeContent=`1` &sortby=`RAND()`]]
    (yes, I know that using the cache like that makes it not so random. Whatever. )

    Anyway, the page flashes onto the screen after a hang.
    It says that mysql is doing 0 things in 0.000 seconds, and that PHP is taking ~10 seconds.


    First, environment:
    (the hosting company posts phpinfo() as a publicly accessible page, believe it or not... I can give the address to you if you want... seems weird to me.)
    server: Linux libraserver 2.6.35-30-generic-pae #56-Ubuntu SMP
    PHP stuff...
    Server API CGI/FastCGI
    PHP Version 5.3.3-1ubuntu9.5
    PDO drivers mysql, sqlite, sqlite2
    ...etc. - I can assure you that the requirements are met; if there are other specifics, just go the the /phpinfo.php file.
    Server stuff...
    Apache/2.2.14 (Ubuntu) w/ suhosin patch
    MySQL client version: 5.1.41
    PHP extension: mysql

    Next, the site: it's got an A at yslow. The only thing wrong is that some of the remote stuff I can't control the expires headers. You can see how fast most things are loading, this is a highly optimized site. Sprites, minified css, post-load widgets, etc.

    I sure hope someone has an idea... I love MODx, it would break my heart if I had to switch to something else. And I know this is my own incompetence, but unfortunately knowing that isn't helping.

    Thanks

    PS: another site which uses really similar code on MODx 2.12, and is not at all optimized in the least, http://tuffcitypowersports.com - it loads ok, but is on a different host. So maybe a hosting thing? Permissions? that's such a black art... who knows, I always think permissions are involved somehow.
      • 36782
      • 109 Posts
      PS: I have some server error logs from a day or two ago - note that modsnippet 30 is getResources:
      [Mon Oct 17 17:03:55 2011] [warn] [client 180.76.5.10] mod_fcgid: stderr: PHP Fatal error:  Call to undefined function parseTpl() in /home/www/electfletcher.com/htdocs/core/cache/includes/elements/modsnippet/30.include.cache.php on line 322
      [Mon Oct 17 17:03:55 2011] [warn] [client 180.76.5.10] mod_fcgid: stderr: PHP Fatal error:  Undefined class constant 'LOG_LEVEL_ERROR' in /home/www/electfletcher.com/htdocs/core/model/modx/error/moderrorhandler.class.php on line 108
      [Mon Oct 17 17:05:09 2011] [warn] [client 157.55.16.229] mod_fcgid: stderr: PHP Fatal error:  Call to undefined function parseTpl() in /home/www/electfletcher.com/htdocs/core/cache/includes/elements/modsnippet/30.include.cache.php on line 322
      [Mon Oct 17 17:05:09 2011] [warn] [client 157.55.16.229] mod_fcgid: stderr: PHP Fatal error:  Undefined class constant 'LOG_LEVEL_ERROR' in /home/www/electfletcher.com/htdocs/core/model/modx/error/moderrorhandler.class.php on line 108
      [Mon Oct 17 17:06:56 2011] [warn] [client 24.108.100.217] mod_fcgid: stderr: PHP Fatal error:  Call to undefined function parseTpl() in /home/www/electfletcher.com/htdocs/core/cache/includes/elements/modsnippet/30.include.cache.php on line 329, referer: http://www.google.ca/search?hl=en&source=hp&q=elect+fletcher&btnG=Google+Search&rlz=1W1GGLL_en&oq=elect+fletcher&aq=f&aqi=&aql=1&gs_sm=s&gs_upl=3218l9343l0l11453l14l14l0l5l1l0l250l1563l0.4.4l8l0
        • 22303 MODX Staff
        • 10,725 Posts
        If you can limit the TVs you are including and processing on those getResources calls, you can greatly improve the speed, especially if you have a lot of TV's attached to each one.

        Also, make sure your tpl's don't have a lot of additional non-cacheable processing.

        Finally, I assume these times are taken when not being loaded from the cache. The cached calls should be almost instantaneous unless your tpl's are full of non-cacheable logic.
          • 22303 MODX Staff
          • 10,725 Posts
          For more information on limiting the TemplateVars you include/process, see the documentation I just updated for includeTVList and processTVList at http://rtfm.modx.com/display/ADDON/getResources#getResources-OtherProperties. This works only in the latest release of getResources, 1.4.0-pl.
            • 36782
            • 109 Posts
            [edit]
            loading from cache takes about 3 seconds on average.
            better than the 10...
            [/edit]

            Hi
            Thnx for the reply. I'll give the tvlist thing a try.
            I don't have anything un-cached, except the getCache calls as in my post above.
            No nested snippets.
            It really is a much more simple site than the other one I linked to...

            Any notion what the php errors could be?

            The manager is very slow too... I wonder if it's some server problem...

            honestly, I need to check the MODx hosting list and just stick to those, and not try to use it for anyone hosted elsewhere, I think. [ed. note: unsub777 last edited this post 14 years, 11 months ago.]
              • 3749
              • 24,544 Posts
              It does seem unusually slow, though you do have a lot of stuff going on for each page. I would suspect an overburdened server. The host may have a page (e.g., in cPanel) where you can view the server load.

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 36782
                • 109 Posts
                Hi,
                Thanks for replying.

                The host says that none of their cores are going over 70 / 80 %.

                Should I maybe try a different method to collect sidebar items? footer items?
                I've never had an issue with this structure before. Just on this one. It must be something I'm doing, but I can't seem to isolate it.

                The question I would have is would any method of making a site like this be any more efficient than getResources? It's a pretty straightforward snippet, isn't it?
                  • 36906
                  • 34 Posts
                  Hi,

                  I've noticed phpthumbof can slow things down for me sometimes when people use large images.

                  I didn't investigate the root cause, just a quick observation.

                  I'd recommend anyone experiencing server performance issues to install some monitoring software like Munin, and then make minor changes to code/config whilst keeping an eye on it.

                  Munin provides graphs for various server processes that can be viewed side by side to get a birds eye view of what is going on - http://munin-monitoring.org/

                  I used to try and guess what was going on by using TOP and VMSTAT, which are good, but it really helps if you can see a chronological graph of it all whilst making considered changes.
                    • 33983 ☆ A M B ☆
                    • 181 Posts
                    I wrote a plugin a few weeks ago that would probably help you: https://github.com/jgulledge19/SuperCache. But it does sound that something is wrong with your host as I have really complex templates and pages and uncached they rarely take much more then 1 second to load the page.
                      • 36782
                      • 109 Posts
                      @TheNewManifesto: Thanks for that, I will try making some changes to the images, or taking out phpthumb.
                      Munin sounds like exactly what I could use right now. Thanks for that, too.

                      @jgulledge19: Supercache looks really good, I will def. check it out. I'm using GetCache snippet now, but it caches on page load, so first visitor will always think the site's broken tongue
                      Am in total agreement that it's a hosting issue, but unfortunately I keep ending up places where they have never heard of MODx, and this last one doesn't have any GUI tools at all, and doesn't allow SSH, haha