Why is my dotCMS slow? How to make dotCMS faster

What usually happens?

So we run into this problem a lot... Let me tell you how it goes...

Customer: my dotcms installation is fine and then some days it just crashes

Ethode: how much traffic is on the site?

Customer: I don't know...

Ethode: how much resources do you have dotCMS running on?

Customer: 1 CPU core and 1GB of RAM...


How to ensure dotCMS is running fast, and not crashing... 

  1. Make sure and give dotCMS enough resources to run.  Really this is #1 and it always should be.  Anyone using to testing out dotCMS needs to understand that dotCMS has a lot happening under the hood. Between Elastic Search, your DB engine, Tomcat, Quartz jobs, and other things there is a reason dotCMS has a "minimum requirements" published.  So that's the first thing, if you don't have dotCMS CE edition running on at least 4GB of RAM and more than 1 CPU core, this is your first problem to fix.  Otherwise not only will dotCMS be slow, but it will crash when ever it gets starved for resources.

  2. Use slim queries.  Yes I know you could easily query and return 1,000,000,000 rows of data, and then loop through them, and then sift through to get the 10 records you actually need.  But if you want dotCMS to run properly you need to make sure and write queries that only return the data you want.  I see this a lot.  They can't figure out why it's resources are so easily consumed on a single page hit, yet that page is eating up enough resources that could normally service 1000 users.  If you need 10 records from your DB or Elastic Search write better queries to get back just the data you need.

  3. Use caching.  It's there, it's easily accessible, it's fast and it's low resources.  If you have 1000 pages, and there's no chance in this decade that those pages will ever change, then you might as well change their page cache to be days months or years, instead of 15 seconds.  If your main source of web traffic is looking at static content, put caching to good use.  All you have to do is right click page, change the caching setting, and save.. Really it's that simple.  If you want to change thousands of pages, you can run a mass query against the pages and update them all at once.. Use caution if you don't know what you're doing though an ALWAYS back  up your database.

    Likewise, if you are accessing certain pieces of data ALL THE TIME and it never changes. Considering writing a plugin to add it as cache.  We have a plugin we've written that will take and add certain fields in a structure to the cache, and we have added a region in the config file for it to use the RAM instead of hard disks.  Not only does this free up that expensive hard drive response times, but it only eats up 6MB of RAM.  Where as running the queries to get this data 1000 times a minute was insanely expensive comparatively.  

    dotCMS Caching tutorial

  4. Scale out, not up - Clustering FTW. For some people it's perfectly okay to scale up.  Matter of fact this is the first move most customers make once they outgrow the minimum requirements is to increase the size of their server (specially in the age of VPS, and Cloud systems).  However, this has a point of diminishing returns.  Even with more CPU and RAM there comes a point where your hard drives can't keep up, or you're pushing to much bandwidth into 1 server to really keep up with the desired speed.  The truth is part of the reason dotCMS is worth it's weight in gold is it's ability to scale (specially with 3.0 auto scaling).  If you have outgrown a single server setup, you need to consider either (a) separating your DB server from your web server or (b) setting up a dotCMS cluster with 3 servers.  2 Web servers and 1 DB server.  If you can spare the cash, you could splurge on a 3rd server for the dotCMS assets (a NAS).  This will give you a setup that can grow as large as you need it too for a long time.  If you get to a point where your installation requires scaling multiple DB servers it's likely you're not using Elastic Search correctly since really most of what you need should come from your index on each cluster node.

  5. Use wise practices.  This is the last and most obvious/easy suggestion.  Sometimes dotCMS isn't the problem.  Sometimes the problem is simply that you have 50 images on your homepage that are 2MB a piece and you're resizing in HTML or CSS on the fly.  Make sure and use a Page Speed plugin in your browser or use Firebug in FireFox to find out what resources on your page are taking inordinate amounts of time to download.  You might need to minify and combine your CSS or Javascript.  You might have to implement sprites for images, but no matter the fact if you're writing bad CSS/HTML and not using best practices there is no amount of tweaking or server resources that make up for bad coding.

Say Hello

Near the Cleveland, Akron or Medina area and want to stop by our office? Let us know and we'll get the coffee and whiteboards ready. :)