We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5160
    • 118 Posts
    Environment

    - Windows Server 2012
    - PHP 5.3.29 with Wincache
    - MySQL 5.6.26
    - MODX Revolution 2.1.3-pl (I know)

    Server has 8 2.2ghz cores and 12gb RAM. Typical use is 40-50% for both CPU and RAM.


    Issue

    The Manager typically takes 20 seconds to open Resources however occasionaly exceeds the max execution time of 30 seconds.

    Other pages eg. Manage Users and Access Controls load in 1 second.


    Background

    The website was migrated to a new server with nearly identical configuration to the original. The website ran without issue before being moved.


    Details that may help identify the issue

    PHP error log for timeout contains a number of errors:

    First
    [23-Mar-2016 17:11:59 UTC] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in C:\net\hosts\domain.co.uk\httpdocs\core\model\modx\modtemplatevar.class.php on line 492
    

    #492 from modtemplatevar.class.php relates to render directories
    if (!$file->isReadable() || !$file->isFile()) continue;


    Second
    [23-Mar-2016 17:11:59 UTC] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in C:\net\hosts\domain.co.uk\httpdocs\core\xpdo\om\mysql\xpdoquery.class.php on line 57
    

    #57 from xpdoquery.class.php is
    $escape = !preg_match('/\bAS\b/i', $column) && !preg_match('/\./', $column) && !preg_match('/\(/', $column);
    

    I don't think these help identify the issue though.

    MySQL does not log any queries taking over 2 seconds to execute.

    Does this indicate an issue on the PHP side?

    Can anyone advise how to investigate further?
      • 5160
      • 118 Posts
      Unsure if this will help pinpoint the issue, today I discovered that resources with no template set load in 2 seconds as expected.

      There is only one template on the affected site and the first thing that comes to mind is that it has permissions to access 49 Template Variables in 7 groups.

      TV types include text, text area, rich text, checkbox and image.

      Think I'll create a test template, restrict the TVs it can access and see if that seems to relate directly to load time.
        • 3749
        • 24,544 Posts
        If this is in the front end and the TVs are all displayed, that would explain it, especially if the TVs require processing, or contain images, or use @ bindings. If you use conditional output modifiers on the TV tags, that will slow things down even more because MODX has to parse them all before getting the TVs.

        The bottom line is that TVs are a terrible place to store data.

        If you want to speed things up, 1) move any TVs that do not contain page-specific data into the template, and 2) move all other TVs into a custom table with ClassExtender.

        If you have a lot of conditional output modifiers (like :ifempty or :default), you might want to consider a custom snippet to create the page output (in addition to the suggestions above).
          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
          • 5160
          • 118 Posts
          If this is in the front end and the TVs are all displayed, that would explain it
          Nope, issue is viewing Resources in the Manager. Most take upwards of 20 seconds to load, sometimes in excess of 30 seconds which hits the max_execution_time time. This is TTFB, not time to load all css/js and other assets.

          Other Manager pages load in 2 seconds eg. Components > Batcher, Security > Manage Users.

          As mentioned above I noticed Resources with no Template Variables load in 2 seconds. So I created a Test Template, assigned it to a test Resource and played with the Template Variables assigned to the template Template.

          The result is TTFB when loading a Resource in the manager is definitely related to the number of TVs assigned to the Template that particular Resource uses. I didn't test the TVs individually to see if the issue is one in particular or the cumulative effect of 49 TVs.

          What I don't understand is why the site was fine on the original server when it was almost identical hardware and configuration.

          There must be a difference but I don't know where to look to figure what needs adjusted.
            • 3749
            • 24,544 Posts
            TVs take almost as much time to populate in the Manager. Are you sure you've made no changes in the site since moving it to the new server? If you haven't, and the servers have the same capability, there must be some difference in how the servers are configured. I'm afraid I can't help you with that, though you might check the PHP memory_limit in phpinfo. You might also look at the variables suggested here.

              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
              • 5160
              • 118 Posts
              TVs take almost as much time to populate in the Manager
              That may be it. Caching could mask the same issue presenting on the front end.

              There have been no changes to the site for many years other than to add news items, each as their own resource.

              I'm convinced there is a difference in the server configuration causing the issue.

              The new server has double the memory_limit of the original.

              I'll need to compare the mysql configurations on each to see if that indicates the source of the problem.

              Will also get a look at your MySQL tuning link.