We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45714
    • 7 Posts
    I have a site that has around 50 users online at any one time and the server keeps crashing. It is on a dedicated 123-reg server and the monitor shows high CPU spikes up to 40% for a single page view with simple cached getresources calls for header/footer and a couple of images using pThumb. The host has indicated high memory usage from Apache causing the server to crash. We had to bring the old website live so we can identify the problem.

    With only one click in the manager dashboard CPU can rise up to 40%. I was contemplating changing getResources on the front-end to PDOtools but feel I might be missing something server related as the CPU and apache memory is still high in the manager?

    The error log shows a lot of these errors Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden:
    but no timeout/memory errors? I'm not sure this would cause memory problems/high CPU??

    Here is the setup:

    Modx Version 2.2.8
    CPU GenuineIntel, Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
    Version Parallels Plesk Panel v11.0.9_build110120608.16 os_Ubuntu 12.04
    OS Ubuntu 12.04.2 LTS

    The site may receive 500+ connections in the future, so it worries me that with only 40 we get server crashes. I have over 40 MODx sites running and have never experienced any issues with server crahshes.

    Any help gratefully received.

    Thanks, David
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      As for the manager spiking the CPU, can you try disabling javascript and css compression (compress_js and compress_css settings) to see if that makes it cool down a bit?

      Thumbnails can definitely spike the CPU; if it's activated you may want to disable the PhpThumbOfCacheManager plugin (not sure if that comes with pThumb as well) and disabling the phpthumb built in cache control. See https://www.modmore.com/extras/moregallery/documentation/thumbnails-performance/#phpthumbcache for instructions on that.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 3749
        • 24,544 Posts
        Another CPU killer can be complex conditional output modifiers, especially if they are in a Tpl chunk and have to be evaluated on each iteration, though that shouldn't affect the Manager.
          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
          • 45714
          • 7 Posts
          Quote from: BobRay at Nov 14, 2013, 11:15 PM
          Another CPU killer can be complex conditional output modifiers, especially if they are in a Tpl chunk and have to be evaluated on each iteration, though that shouldn't affect the Manager.

          Thank you for your help.
          Here is the 'what's on' tpl with conditional statements. It displays what's on items in boxes left to right and every 4th box creates a new line (closes the div row). Is there a work around to make the below more efficient? relatedboxes chunks are very similar so I only included one below: Thanks, David

          <div class="childrow">[[getResources:default=`<!-- no results --></div>`? &parents=`[[+id]]` &limit=`20` &depth=`1` &tpl=`relatedboxes` &tpl_n4=`relatedboxes4` &tplLast=`relatedboxeslast` &includeTVs=`1` &includeTVList=`thumbImage,tv.mainImage,propertyImage` &sortbyTV=`eventDate` &sortdirTV=`ASC` ]]

          then related tpl:

          <div class="childpage [[+total:is=`1`:then=`colfull`]]
          [[+total:is=`2`:then=`colhalf`]]
          [[+total:is=`3`:then=`colthird`]]
          [[+total:isgte=`4`:then=`colquarter`]]">


          <div class="childbox">

          [[+tv.thumbImage:notequalto=``:then=`<a href="[[~[[+id]]]]"><img src="[[+tv.thumbImage:phpthumbof=`w=420&h=310&zc=1`]]" alt="[[+pagetitle]]" class="scale-with-grid" /></a>`:else=`

          [[+tv.tv.mainImage:ifnotempty=`<a href="[[~[[+id]]]]"><img src="[[+tv.tv.mainImage:phpthumbof=`w=420&h=310&zc=1`]]" alt="[[+pagetitle]]" class="scale-with-grid" /></a>`]]


          [[+tv.propertyImage:ifnotempty=`<a href="[[~[[+id]]]]"><img src="[[+tv.propertyImage:phpthumbof=`w=420&h=310&zc=1`]]" alt="[[+pagetitle]]" class="scale-with-grid" /></a>`]]

          `]]

          [[*includelongtitle:isequalto=`yes`:then=`<h4>[[+longtitle]]</h4>`]]
          <h3><a href="[[~[[+id]]]]">[[+menutitle:default=`[[+pagetitle]]`]]</a></h3>

          <p class="intro-child" style="border-bottom:0">[[+introtext]] </p>

          </div>
          <div class="clear"></div>
          </div>
            • 3749
            • 24,544 Posts
            The problem is that those thumbnails are all going to be generated whether the left-hand TV is empty or not.

            See this: http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/
              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
              • 45714
              • 7 Posts
              Quote from: BobRay at Nov 15, 2013, 01:44 AM
              The problem is that those thumbnails are all going to be generated whether the left-hand TV is empty or not.

              See this: http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/

              Thanks. i have used - will report back speed improvements soon. Love your book btw!

              [[[[+tv.tv.mainImage:notempty=`$wrapImgThumb? &src=`+tv.tv.mainImage` &url=`[[~[[+id]]]]` &alt=`[[+pagetitle]]` &thumbOpts=`w=420&h=310&zc=1``]]]]
                • 3749
                • 24,544 Posts
                Thanks for buying my book. smiley
                  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
                  • 47401
                  • 295 Posts
                  hi bob, i am also experiencing the same issue sad

                  ps

                  I also brought your book smiley great book it is too
                    • 3749
                    • 24,544 Posts
                    Using TVs for selecting resources is the root of this problem, but that's compounded by the need to parse and process the conditional output modifiers.

                    The only real solution is a custom snippet, though you can speed things up some by using PdoResources, proper tags (see Jason's post in the link above), and not using default values or @ bindings for the TVs.

                    An even faster solution is to extend modResource and put the data in the TVs into a custom DB table.

                    I have a blog post on this due out soon.
                      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
                      • 40045
                      • 534 Posts
                      as for the manager, do you eventually have a lot of images that are displayed in the media manager (for image selection, upload etc.)? Just a guess, but had similar issues on a very "well hung" server crashing mainly because of the way how the media manager thumbnails are generated (basically trough a php file with some params -> this causes them to not be cached in the browser and thus they are "processed" [not generated though] each time the media manager is visited)...had to hack the core to a) serve the thumbs as real images, so they can be cached properly in the browser and b) by replacing the default use of phpthumb with alternative code to use pthumb to generate the thumbs initially...