Performance tips for Movable Type

Overview

Movable Type is a very powerful platform for publishing content online. It provides a robust API for developers to use, as well as a very useful template tag language that is based on XML. However, in many envi ronments online, Movable Type is hampered in performance by the limitations of a shared hosting environment. This is something that those of us who have been Python fans have lamented for years, as many hosting services won't even install common, stable modules for Python such as database support. That said, ther e are things that you can do and look for that will help you speed up the performance of Movable Type in a shared hosting environment.

Rebuilding

By default, Movable Type publishes content statically. This has some advantages and disadvantages to it. The obvious advantage is that unlike dynamic publish ing systems like WordPress, a Movable Type-based website will generally do better under a heavy load because it doesn't have to generate the content on the f ly or by coupling dynamic content with cached template chunks. The disadvantage is that in order for a change to be reflected in a post, every file that refe rences the post must be updated. When a new entry is added, the main page must be rebuilt, the news feeds must be rebuilt, an individual archive must be buil t, and all of the archive templates must be rebuilt. That can be a lot of work to do under a heavy load.

What I have done to speed up rebuilding w as to cut out archives that I don't need. A standard installation of Movable Type 4 will provide archive mappings for individual archives, monthly archives, category archives, monthly category archives and author monthly archives. That's probably a lot more archives than you will really want or need . For me, that was definitely the case. I cut out all of the category mappings and the author monthly mappings. These settings are available under Design-> ;Templates in the Movable Type menus, and can be found under the sidebar entry for "Archive Templates" under "Entry Listing" as of Movable Type Open Source 4 .1.

Widgets

Be careful about the widgets that you include in your sidebar on your blog. Widgets that load information out of the database, which is going to be many of them, will take a small amount of time to process the data that you want bundled into the sidebar. You may be tempted to put a lot of widgets there, such as recent comments and things like that. However, these widget choices may be just clutter on your sidebar that ends up having the unwanted side effect of slowing down the rebuilding of your blog. As always, there's a trade off.

Spam

One step that you can take to cont rol the flow of spam, and how it affects your blog's performance is to set up Movable Type to hold all trackback pings for moderation before they get publish ed. You can find this setting under Preferences->Blog Settings in the Movable Type menu. This is probably a good idea anyway, as bloggers often find legit imate pings from other bloggers that have no link back to their blog. This is a good way for you to make sure that people aren't just trying to use your trac kback system to promote their website.

Finally, if you deal with a repeat spammer, you can use a .htaccess file to make it so that Apache will jus t block their IP address altogether. This is a good tutorial.

Caching

Arguably the best way to increase performance on your Movable Type blog or website is to use caching. As its name suggests, caching allows you to reuse conte nt from one rebuild to another. For those who are using Movable Type 4.1 or earlier, Cache Block is an exce llent plugin to enable caching. For my blog, I have seen it reduce a rebuild of the entire site from about 25-30 minutes down to about 6-7 minutes for about 1,200 entries and pages (plus archives, as of 3/31/2008). Version 4.1.5 is g oing to include built-in support for caching.

Obviously, the best use of caching is to cache the maximum amount of content as possible. Just be careful to cache only content that should be static such as the header and footer HTML. Be aware of dynamic content that might be in blocks of template data that is otherwise static, such as function tags for author and page information, or the entry title (this is the case in the header template). If you have a well-laid out sidebar, it is possible to get some pretty si gnificant gains here by caching the entire sidebar.

Misc

PHP versus Perl -- why the speed difference? PHP comes in two main forms: a server module and a CGI binary. The server module stays loade d as long as the server is loaded, which means that the module never has to be reloaded when a request for the file type handled by the module is made. PHP i s installed as an Apache server module by most hosting services, but they do not provide mod_perl, which is the equivalent server module for Perl. This means that a request to a Perl file must be handled by the regular Perl interpreter. If PHP had to work this way on most hosts, you can bet that there would be a lot of complaints about the performance of PHP applications! This is why if you are looking at a publishing system for your organization, you ought to look a t getting mod_perl installed on your server. Since you have control over the system, you can install these performance-increasing modules to make Perl applic ations run faster.