0

We are currently trying to improve one of our project's performance and therefor I try to understand factors that influence a page's rendering time and memory consumption.

Before optimizing complex pages with element queries I want to optimize a minimalistic twig template without any element query. This is the template:

<html> <head> <title>Testing</title> </head> <body> <h1>Testing</h1> {% if craft.app.config.general.devMode %} <p>Dev Mode is <strong>enabled</strong>.</p> {% else %} <p>Dev Mode is <strong>disabled</strong>.</p> {% endif %} {% if craft.app.config.general.enableTemplateCaching %} <p>Template Caching is <strong>enabled</strong>.</p> {% else %} <p>Template Caching is <strong>disabled</strong>.</p> {% endif %} </body> </html> 

I put the template into the templates/ folder and call it directly.

I tried this on 3 different projects in production and enabled the frontend debug toolbar for my user. All 3 projects have almost the same setup: PHP Version (8.2), Craft Version (4.15.0.2), same machine, there are only differences in plugins, sections/entrytypes/entries and some minor module differences.

Interestingly I received 3 different results for the 3 projects:

  • 50ms rendering time and 1,5MB mem consumption
  • 65ms and 5MB
  • 180ms and 20MB

Next I cloned the slowest project to a second instance on the same machine and:

  • one after the other disabled all plugins: (almost) no change in rendering time and memory
  • removed all modules: no effects
  • removed almost all elements using the console command elements/delete-all-of-type: nothing
  • cleared all caches: nothing
  • did garbage collections: nothing

To be honest: I do not understand it. It's like Craft ignores my wishes to get a better understanding:

Do you have any other ideas? Or give me a hint on what is actually influencing rendering time and memory consumption?

1 Answer 1

0

It sounds like you’re working backwards.

I would start with 3 identical projects. Get a baseline reading for each of them (I’d include number of DB requests, too). Note also, if hosting on a VPS, that virtual memory and swap usage can affect the performance of the site.

Then incrementally add content, modules, plugins, etc., taking benchmarks at each step.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.