Help! The run-periodic-tasks script is consuming too much CPU!!
Users of Movable Type, especially those whose systems have grown complex in one way or another, may often run into the problem whereby Movable Type begins to consume an inordinate amount of memory or CPU. These users will often jump to the conclusion that Movable Type is inherently flawed, or slow, or both.
What is important to understand when faced with a problem such as this is the following: Movable Type is a publishing platform. This means that Movable Type is rarely, if ever, deployed strictly by itself. In almost all circumstances we have encountered Movable Type is deployed in conjunction with numerous plugins, and often with complex code (both in the form of PHP and templates) and for large environments, is often deployed across numerous servers. In systems this complex, the system as a whole is only as fast or as strong as the slowest or weakest component.
So the trick is in isolating these bottlenecks and then understanding how to alleviate them.
What this article is geared to address is how one is to go about addressing the problem of Movable Type consuming too many resources, and what it might be indicative of. Finally it will provide you with a few readily available resources to help you isolate the problem yourself, without the need of contacting a costly professional. Let's begin.
Diagnosing the Problem
Movable Type, by itself, with no other software installed, and with its default templates is capable of scaling a great deal. In fact, the makers of Movable Type have invested a great deal of time into developing the test suites and infrastructure necessary to guarantee it to a certain extent.
So at a very high level, to properly diagnose a performance or resource utilization problem, what one must immediately turn their attention to is this:
How has my system been changed since it was installed?
Obviously the answer to this question will vary from person to person, but most often performance problems can be traces to one or more of the following:
- Configuration - e.g. the
mt-config.cgifile has been heavily modified and/or customized
- Plugins - numerous plugins are often installed to make possible certain features not native to Movable Type
- Templates/Themes - templates have been modified, or perhaps completely rewritten to facilitate unique design or functional needs
Let's drill into each of these a little bit more.
Without proper knowledge, any piece of software, no matter how perfect or robust, could be configured to run poorly. Movable Type is no exception. So one of the first things we look for are a few configuration directives found within MT's
mt-config.cgi file. One thing you can check for yourself is:
LaunchBackgroundTasks- This should be turned off. Learn more.
Other configuration directives may possibly provide hints as to where else to look, but we recommend contacting a professional who can best ascertain how various directives may interact in a non-obvious way, or combine to degrade the performance of a system.
There are too many plugins installed!
Often people will conclude that the more plugins a MT install has, the slower that system will get. And while that can be true, it is not always true. That is because while every plugin will add slightly to Movable Type's overall memory footprint, plugins are not completely loaded into memory until their code needs to be invoked. In this way, Movable Type loads plugins in a JIT (just in time) fashion.
Some plugins are known to be performance killers. More often than not they are plugins that are great for small sites, but have not been adequately designed or architected to handle issues that only arise when operating at scale. This list of "know offenders" is actually constantly changing thanks to an active developer community that works to address problems when they arise. To see if your system uses one of these plugins, consider contacting a professional and asking them for advice.
Nine times out of then, a performance problem can be traced to a user's templates. That is due to the fact that Movable Type places a great deal of power into a user's hands - in the form of a programming language called the "Movable Type templating language." And like any programming language, code that is written without proper planning and consideration will often contain errors, or contribute negatively to performance.
These problems are often very difficult to diagnose. That is why Endevver has created a plugin to help users audit their templates to determine in what ways they might be contributing to a system's performance. The plugin is called Template Profiler. It works by compiling a template and inspecting in detail each template tag that is invoked when publishing that template. It then produces a report showing you how much time each tag took to processing, how many times it was invoked, etc. What you should be looking for are outliers. Look for any statistic that is significantly different from its counterparts. It will indicate the template tag, and the template that is the source of your problem. Armed with that information may help lead you to a plugin or a coding technique that might be exacerbating your system.
The next plugin is Endevver's Template Optimizer. Unlike the Template Profiler plugin which looks at a template's content, the Template Optimizer plugin looks at the templates configuration to determine whether or not it conforms to best practices. For example, does the plugin utilize server side includes effectively? Does the module utilize template module caching? Is the template set to publish statically or via the publish queue? Etc. This plugin can very quickly rectify many problems a system might have in an automated and reliable fashion.
The Be-All and End-All
Finally, if you system is seemingly beset with problems, often the most cost effective thing to do is have a professional audit the system looking for a larger range of problems. That is precisely why we have crafted the Movable Type Performance Audit. Take a look at the sample report and see if this is something that seems right for you.