How to optimize memory and speed?

Hi,
I have a new installation with some websites. I migrated from CentOS with VestaCP to Debian 11 with HestiaCP.
I am very happy with the end result but it seems that my websites respond slightly slower than before.
However, it is on the same VPS server (5Gb ram).
How can I optimize the use of memory and the speed of the initial loading of the websites?
I know this is a complex question but maybe there are some best practices for HestiaCP?
Thanks.
Verus.

What is your setup? Nginx / Apache or Nginx only? Wordpress, other cms?

It is a basic setup with Apache and Nginx.
Websites are only wordpress. That’s about it.
Thnx.

It’s very little information to help you… speeding up WP can be very case dependant. In general I have the same setup with Nginx proxy. I feel I almost never need any additional caching plugins for my custom-build installs with as little plugins as possible. In some cases I use Cloudflare with a caching plugin.
The best thing to do is to analyse your websites to find the cause of the slowing down. Test your sites with: https://gtmetrix.com/, https://pagespeed.web.dev/ and the likes…

You can have 100 wordpress sites running in a machine or even 2 woocommerce sites running in that machine.

The optimization has nothing to do in this cases.

Universal guide:
1.) GitHub - masonr/yet-another-bench-script: YABS - a simple bash script to estimate Linux server performance using fio, iperf3, & Geekbench

wget -qO- yabs.sh | bash

You must to have more than this:

Geekbench 5 Benchmark Test:
---------------------------------
Test            | Value                         
                |                               
Single Core     | 468                           
Multi Core      | 456                           
Full Test       | https://browser.geekbench.com/v5/cpu/6936264

I.e. Single core > 800 = normal, okay performance.
More than 1000 = great core performance. I.e. very good provider.
< 700, but > 500 = normal, but can be better.
< 500 = awful provider, avoid the provider at all costs.

The rest part related to disk:

  • must be ssd / nvme with high iops. High = how much is that? > 1.000

That’s from where everything starts: CPU performance & Disk performance.
RAM not really important. Ram = it’s fast, and there can’t be so much issues in 2022. I mean i can write long story about ram, but in short - ram not important.

When you have fast enough KVM VPS or dedi server you can go to next step:

2.) classic installation of hestiaCP by command on website - will result in “for all solutions good setup, but in cost of performance”. I do not like it. It’s slow. Apache always slow. I hate apache. It’s sucks.

But what to do?
hestiaCP great, and can help you to install nginx + php + mysql/mariadb without apache.

How to do that?
https://gabizz.github.io/hestiacp-scriptline-generator/

For example:

wget https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install.sh

sudo bash hst-install.sh --apache no --phpfpm yes --multiphp no --vsftpd no --proftpd no --named no --mysql yes --postgresql no --exim yes --dovecot yes --sieve no --clamav no --spamassassin no --iptables yes --fail2ban no --quota no --api yes --interactive yes --hostname no --email no --password no --with-debs no  --port '8083' --lang 'en'   

This is just example. Try to play with settings, maybe you find your best. I do not need anything else. So it’s pretty minimal installation.

When you will setup that, you will have nginx + php (latest version) + mysql (or mariadb, does not matter).

3.) Login to control panel, to your user.
Edit web domain → Advanced Options → Web Template → Wordpress.
cache duration → 5m, 10m, whatever. If you have a lot of dynamic content, you can make microcache. I.e. write there 30s. It will be great too. I like 10m.

4.) Now your website will be crazy fast. Not need to install any caching plugins, whatever. ALl of them sucks.

If you wanna add extra important changes, i suggest to:

  • remove 3rd party code which loaded from 3rd party domains (chat widgets, help desks, analytics, fonts, images from 3rd party domains, etc)
  • you can install autoptimzie to concatanate all resources into one to reduce requests
  • not much else can be done without deep understanding about your website

5.) if everything above does not help (which is strange)
Enable debug, install debug plugin for your wordpress. Trace delays. Probably can be related to a lot of sql queries.
For such case you can install php-redis & redis plugin. It will be damn fast too because of cached requests.

Hope it will help you.

4 Likes

Thank you for your good explanation.
Everything seems ok when I test it but the initial first load is slow. Especially the initial load of the posts site.
I already tried a lot but I have no idea why it takes so long.

Maybe you are dealing with a slow database query that gets cached and the cached response is much faster

Are there possibilities to optimize how my database works with Hestiacp and wordpress?

Use well programmed themes and plugins so that they do not perform multiple queries or inefficient ones

Install redis + phpx.x-redis and it will help a bit

Thanks, that helped also.
The solution was the combination of the following:

  • wordpress plugin Merge + Minify + Refresh

  • nginx fast cgi cache

  • Redis server

  • removing yoast SEO and replacing it by “the SEO framework” (however I don’t know if that has a big impact).

Now the first initial load of the website is really fast, I am very happy with that! :slight_smile:
I tested that on my smartphone and also on a smartphone that never connected with the website before.

Thnx 4 the feedback.