Elgg 4 became slower

I just updated my site from Elgg 3 to Elgg 4 and I report that the site has become slower.

I turned off third party plugins (Group tools, Profile manager), it speeded up my site a bit.
However, compared to Elgg 3, it's still slower.

Does anyone have a similar problem?

PS: PHP 8.1 is used.

  • Well, I benchmarked two sites (elgg 3.3.24 and 4.3.1) and here's what I found.

    Elgg 4 makes more database queries under the same conditions than Elgg 3.

    Sometimes it increases the load avarage:

    Elgg 3: ~0.8.x ~0.2.x ~0.1.x
    
    Elgg 4: ~3.x ~2.x ~1.x

    But it always increases the load on the processor:

    Elgg 3: ~10%
    
    Elgg 4: ~50%

    Enable the logging in PHP (slow log) I found the following slow requests:

    preg_match() vendor/matthiasmullie/minify/src/Minify.php:298
    replace() vendor/matthiasmullie/minify/src/CSS.php:316
    execute() vendor/matthiasmullie/minify/src/Minify.php:149
    minify() vendor/elgg/elgg/engine/classes/Elgg/Views/MinifyHandler.php:39
    __invoke() vendor/elgg/elgg/engine/classes/Elgg/HandlersService.php:63
    call_user_func() vendor/elgg/elgg/engine/classes/Elgg/HandlersService.php:63
    call() vendor/elgg/elgg/engine/classes/Elgg/PluginHooksService.php:69
    trigger() vendor/elgg/elgg/engine/classes/Elgg/Application/CacheHandler.php:343
    getProcessedView() vendor/elgg/elgg/engine/classes/Elgg/Application/CacheHandler.php:124
    handleRequest() vendor/elgg/elgg/engine/classes/Elgg/Application.php:422
    run() vendor/elgg/elgg/engine/classes/Elgg/Application.php:345
    route() vendor/elgg/elgg/engine/classes/Elgg/Application.php:395
    index() index.php:8

    I'm sure that caching in Elgg 3 works better than in Elgg 4.

    I don't have a clear answer as our sites are different, maybe my report will give you the true way and you'll come back having learned the reasons why your site is so slow.

  • This experience proves that version 3 is faster and consumes fewer resources than version 4. This is strange. I think that updates may contribute to increasing the speed of the site and reducing resource consumption. We aspire to re-improve the performance of the script and work to improve its performance and reduce its consumption of resources

  • We tried to keep the performance similar between 3.3 and 4.0 (otherwise our client wouldn't accept the upgrade ;).

    That said, performance depends on many factors (hardware, network, plugins, etc).

    As far as I remember it was quit similar. During the development of Elgg 4 we improved the performance, this had a lot to do with caching, as we switched to a different caching library and some configuration improvement were made.

    It is possible that Elgg 4 requires more resources, I don't remember exactly. We try to reduce this as much as possible, for example the number of database queries is something we try to reduce as much as possible.

    A tip I can give is check the new settings.php file in Elgg 4 for the added options when compared to Elgg 3. This can help with performance.

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.