We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7653
    • 11 Posts
    Hi there,

    We’ve recently launched a site for a client using modx 1.0.4 and it’s been running fine under test conditions but under load it starts eating up all the server resources and eventually hanging.

    It is a pretty complicated site - it has multiple domains which are all controlled by .htaccess and it also pulls in resources from various APIs. However, from our testing we think the problem lies within connecting to the DB.

    Here’s an error message we got when one of the pages crashed...

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - MySQL server has gone away »
    SQL: SELECT id FROM br_brands WHERE modxID = 99
    [Copy SQL to ClipBoard]

    Parser timing
    MySQL: 0.0038 s (26 Requests)
    PHP: 208.0937 s
    Total: 208.0975 s


    Wondering if this is something to do with modX persistent connections failing but not closing and eventually leaving the DB uncontactable but PHP still vainly trying to connect and chewing up all the server memory.

    I would give you full server details but we’re currently locked out sad

    Assume a typical linux apache/mysql/php setup running under cPanel with all necessary modules installed.

    Any thoughts appreciated!

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It’s been mentioned before that hosting tech support has recommended not using pconnect.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7653
        • 11 Posts
        Found out that persistent connections are disabled from the server.

        Currently it’s looking like how we were pulling in data from fb/twitter/4sq. The api calls werent closing correctly and ended up eating all the resources. We’ve forced their closures now and resource usage is down to reasonable levels (fingers crossed)
          • 7653
          • 11 Posts
          Ok new update..

          Looks like loads of zombie processes spawned in Apache and they were slowly using up all available memory. Whats weird though is that we started cutting back and back on what scripts were running to try and isolate the script(s) causing the problem.

          We had some cron jobs running via lynx and we had commented them out. When running top we noticed that the script which just had opening and closing php tags in, was also spawning a zombie. So the simple act of calling php, created a zombie.

          This was running under apache 2.2. with php 5.2.14

          Anyone had anything like this?
            • 7653
            • 11 Posts
            Another update (in the hope someone can shed some light on this)

            Turning off htaccess and stress testing a php page that just echoes ’hello’ spawns loads of zombie processes and will lock up all server cpu.

            This isnt calling a modx page and afaik modx isnt involved at all. Would modx change anything in php to cause this? Would modx get called when Im linking directly to this php file and htaccess is off?

            To clarify...
            Page I’m calling is in the document root and is called hello.php.
            htaccess is off so modx shouldnt be getting called.

            Just looking to see whether this issue is with modx, or php or server configs.


            PHP 5.2.14
            php running as suPHP
            Mysql 5.1.51
            Apache 2.0.63
            modx 1.0.4

            and plugins we’re using..

            * PHx (10)

            # Manager and Admin

            * EditArea (11) - 0.5.2 - Allows text formatting, search and replace and real-time syntax highlighting
            * Inherit Parent Template (1) - 1.1 Newly created Resources use the same template as their Parent or Sibling Containers
            * ManagerManager (2) - 0.3.8 Customize the MODx Manager to offer bespoke admin functions for end users.
            * TinyMCE Rich Text Editor (4) - 3.3.5.1 Javascript WYSIWYG Editor
            * TransAlias (5) - 1.0.1 Human readible URL translation supporting multiple languages and overrides

            # Search

            * Search Highlight (3) - 1.5 Used with AjaxSearch to show search terms highlighted on page linked from search results

            # uncategorized

            * Google Analytics (15) - 1.6 Adds Google Analytics code to every page in your site
              • 22303 MODX Staff
              • 10,725 Posts
              That definitely sounds like a problem with the server configuration.
                • 7653
                • 11 Posts
                Thanks thats the assumption I’m going on currently. Now setting it up on a friends VPS.

                Just to clear my mind - there’s no way hello.php would be calling modx if htaccess is off?
                Also modx wouldnt change any default php configurations? Although I understand it might alter them if it was serving the pages? Is that correct?
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  It might alter run-time settings, but it would only be effective when MODx is running (i.e. index.php has been requested). If you’re going straight to a .php file, MODx isn’t involved at all.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 7653
                    • 11 Posts
                    Ok new update - just finished testing on a new VPS.

                    Stress test was this...

                    ab -n 1000 -c 250 http://www.domainname.com/

                    So that simulates 1000 requests with 250 concurrent requests - not what I would call a heavy load but certainly not a light one either.

                    Testing against a static html page, a php page with phpinfo() in and another php page that just echoed "hello World’ and all results were fine. cpu usage stayed above 95% and apache usage per thread never went about 0.2% cpu and 0.1% memory.

                    Then I installed modx 1.0.4 with its sample site and ran the test against that.

                    Free cpu dropped to 0% almost instantly and even though I’ve stopped the tests the entire VPS is down (can ping it but that’s it).

                    So server config could probably be tweaked to help things but it does seem like modX needs some tweaking too. I’ll look into ways of optimising modX but any suggestions / recommendations are very welcome




                      • 7653
                      • 11 Posts
                      Quote from: sottwell at Dec 04, 2010, 09:54 AM

                      It might alter run-time settings, but it would only be effective when MODx is running (i.e. index.php has been requested). If you’re going straight to a .php file, MODx isn’t involved at all.

                      Thanks for clearing that up Susan