Craft CMS performance tips
Published
Updated
The usual causes of a slow Craft CMS site on fortrabbit, and where to fix each one, from database queries and image transforms to the queue and caching.
About Craft CMS performance
Most slow Craft CMS sites in our support share a few causes. Start by finding where the time goes: the metrics and logs of the environment show whether PHP, memory or the database is the bottleneck. The general performance section covers what applies to any PHP app, including PHP processes and scaling.
Common causes
| Symptom | Likely cause | Fix |
|---|---|---|
| 504 on image upload or first page view | Image transforms | Image transforms |
| Slow pages, many queries | Element queries | Database queries |
| Site slow while editors work | Queue in web requests | Queue jobs |
| Memory kills | Transforms, bulk updates | Out of memory |
| High disk I/O | Cache without key | Caching |
| Load from bots | Uncached 404 pages | Caching |
Blocking PHP requests
A PHP process is busy as long as it is executing. When all of them are busy, the site stops answering. Examples from support:
- A plugin queries an external service in a blocking way and the answer takes too long.
- The database is overwhelmed by too many or too expensive queries.
- Image transforms or the queue run in the PHP processes that serve the site.
Dev mode in production
Keep CRAFT_DEV_MODE=false on fortrabbit, as the software template sets it. In dev mode, Craft logs more and writes verbose log files, which costs time on every request. See production settings.
Further reading
Ryan Irelan has educational video content on CraftQuest, some paid, some free: