The Hidden Downside of Embedding Joomla Modules in Articles

One of the really nice features that Joomla has is loading modules within articles using loadmodule or loadposition (or using an 3rd party extension such as Modules Anywhere). It is an excellent functionality that permits Joomla administrators to leverage the power of modules within articles (or even within modules if using Modules Anywhere).

That flexibility, however, comes at a cost: embedded modules are only cached when the System – Page Cache plugin is enabled (and we all know how fun it is to have this particular plugin enabled).

This means that if you have some heavy queries running in those embedded modules, then expect those heavy queries to run every time even if you are using conservative or progressive caching (see this post for the difference between the two). Yes – that’s not optimal, and unfortunately, there are no workarounds that don’t involve substantial modifications to the core.

How did we discover this?

Well, we discovered this whole thing by accident (just like when Alexandar Graham Bell discovered the phone, and just like when Christopher Columbus discovered America): we were analyzing the queries that a certain website was sending to the database server in a silo’d environment, and we noticed that all the queries loading the modules were not being executed when either the conservative or the progressive caching, with the exception of the embedded modules.

You can try this yourself:

  • Copy your website to a development server.
  • Enable Conservative Caching in your global configurations settings.

  • Add the following lines to the my.cnf file (the my.cnf file is the MySQL configuration file, which is typically located under the /etc folder) in order to catch all the queries that are sent to the database server (you can use vi or nano to edit the file – we prefer vi):

    general_log = on
    general_log_file=/var/lib/mysql/all-queries.log

  • Restart MySQL by issuing the following shell command:

    service mysql restart

  • Visit the website using your browser, and then clear the all-queries.log file by issuing the following command:

    > /var/lib/mysql/all-queries.log

  • Visit the website again, and you will see that all the queries pertaining to those embedded modules are still being sent to the MySQL database server and recorded in the all-queries.txt file.

So yes, while embedding module is a very powerful concept, it also comes at a price. For some modules and some websites, that price is very expensive in terms of performance. On the bright side, however, for most websites and most modules, the price for doing that is almost negligible.

If your website has a lot of embedded module and you are noticing performance issues caused by these modules, then just contact us. Our prices are affordable, our work is professional, and we always have a solution for anything Joomla!

No comments yet.

Leave a comment