I have two sites running modx. Both of which have simple templates mainly using getResources and Wayfinder.
I’ve noticed, the first time you hit a page after clearing the modx site cache it can take up to 8 seconds to render the page. This is terribly slow.
What are the usual reasons for such slow performance - or, is this in fact quite normal?
I need to find a way of bringing that page generation time right down to about 2 or 3 seconds. Pages which are current in the modx site cache take about 3 seconds which is, although not ideal, within acceptable tolerances.
I’m happy to provide any information to help get to the bottom of this...and perhaps we can share some learnings for those who follow us.
-
MODX Staff
- 10,725 Posts
FWIW:
In 2.0, when you clear the cache, the context cache has to be generated by querying every resource and all of it’s parents to build the virtual URI it responds to in MODX. The long page generation after clearing the cache is due to this.
In 2.1, when you "refresh" the cache, the context caches are all recreated (never deleted) from a single query using the new uri field. This helps immensely if you clear the cache often during peak traffic times. There are numerous other speed improvements in MODX Revolution 2.1.x as well that should help with whatever is causing your slow performance issues.
I’ve got one site running 2.1.1 which has 5 nav items surfaced through wayfinder on its homepage.
And then the 2.0.8 site - I’ve just checked and in fact its nav is just hardcoded but the homepage template does have about 3 or 4 custom template variables which just spit out text (but via filters like nl2br and a string shortener)
So one would think the latter should render very fast.
Output modifiers can slow things down a lot (especially conditional ones) because each output modifier has to be identified, parsed, and then executed separately.
Replacing them with custom snippets can sometimes make a big difference.
On the 2.0.8 site homepage we have just one TV rendered through output modifiers as follows:
[[*HomepageAnnouncement:nl2br:shorten=`170`]]
(shorten is an excellent snippet if anyone’s used it before)
I’d be very surprised if the above slowed render times down that much.
In your first post you said that both sites were running getResources and Wayfinder. If that’s the case, they are the most obvious causes of performance issues so at least rule them out by running Executioner on each one and noting how long they take to execute.
Let’s start with the 2.0.8 site
ENV INFO:
MODx version: Revo 2.0.8-pl (trad)
Codename: Revolution
ExtJS: 3.3.0
Smarty: 3.0.4
PHPMailer: 2.0.4
MagpieRSS: 0.7a
Database type: mysql
Database version: 5.1.49
Database charset: latin1
MySQL Support: enabled
Active Persistent Links: 0
Active Links: 0
Client API version: 5.0.67
MYSQL_MODULE_TYPE: external
mysql.allow_persistent: Off,Off
mysql.connect_timeout: 60,60
mysql.max_links: Unlim,Unlim
mysql.max_persistent: Unlim, Unlim
PDO support: enabled
PDO drivers: mysql, pgsql, sqlite, sqlite2
PDO Driver for MySQL, client library version 5.0.67
Host Info
Type: Shared Hosting
Stack: Linux, PHP 5.2.14 (Apache CGI), Apache, MySQL 5.0.67
Error Log - is empty
I’ll try the executioner later on and see if that sheds some light on it. If we can get the 2.0.8 running like a well-oiled machine, we can tackle the more complex 2.1.1 site. Get both of these working and I’m also hoping that we have a useful thread on here for others in the future.
Now on the 2.0.8 site, we have a product index page which uses Wayfinder to pull in the page titles of 10 items (nothing else other than page title and url) and here’s what Executioner has to say
[2011-07-14 14:03:53] (ERROR @ /index.php) modSnippet: Wayfinder executed in 1.2907 s
Wow.