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.

Hi @desp, this is an amazing tutorial! Do you maybe have an updated numbers for the single core performance for the updated Geekbench 6 Bencmark Test?

Ryzen on almost dedicated cores.

curl -sL yabs.sh | bash -s -- -s https://www.vpsbenchmarks.com/yabs/upload
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
#              Yet-Another-Bench-Script              #
#                     v2023-04-23                    #
# https://github.com/masonr/yet-another-bench-script #
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #

Tue May  9 04:33:38 PM UTC 2023

Basic System Information:
---------------------------------
Uptime     : 0 days, 0 hours, 0 minutes
Processor  : AMD EPYC-Rome Processor
CPU cores  : 2 @ 2844.654 MHz
AES-NI     : âś” Enabled
VM-x/AMD-V : ❌ Disabled
RAM        : 1.9 GiB
Swap       : 5.8 GiB
Disk       : 56.1 GiB
Distro     : Ubuntu 22.04.2 LTS
Kernel     : 5.15.0-71-generic
VM Type    : MICROSOFT
IPv4/IPv6  : ✔ Online / ❌ Offline

IPv4 Network Information:
---------------------------------
ISP        : The Constant Company
ASN        : AS20473 The Constant Company, LLC
Host       : Vultr Holdings LLC London
Location   : City of London, England (ENG)
Country    : United Kingdom

fio Disk Speed Tests (Mixed R/W 50/50):
---------------------------------
Block Size | 4k            (IOPS) | 64k           (IOPS)
  ------   | ---            ----  | ----           ----
Read       | 509.21 MB/s (127.3k) | 1.19 GB/s    (18.6k)
Write      | 510.55 MB/s (127.6k) | 1.20 GB/s    (18.7k)
Total      | 1.01 GB/s   (254.9k) | 2.39 GB/s    (37.4k)
           |                      |
Block Size | 512k          (IOPS) | 1m            (IOPS)
  ------   | ---            ----  | ----           ----
Read       | 1.40 GB/s     (2.7k) | 1.44 GB/s     (1.4k)
Write      | 1.47 GB/s     (2.8k) | 1.54 GB/s     (1.5k)
Total      | 2.87 GB/s     (5.6k) | 2.99 GB/s     (2.9k)

iperf3 Network Speed Tests (IPv4):
---------------------------------
Provider        | Location (Link)           | Send Speed      | Recv Speed      | Ping
-----           | -----                     | ----            | ----            | ----
Clouvider       | London, UK (10G)          | 9.08 Gbits/sec  | 7.08 Gbits/sec  | 0.721 ms
Scaleway        | Paris, FR (10G)           | busy            | 7.11 Gbits/sec  | 7.53 ms
NovoServe       | North Holland, NL (40G)   | 13.7 Gbits/sec  | 15.9 Gbits/sec  | 6.15 ms
Uztelecom       | Tashkent, UZ (10G)        | 3.70 Gbits/sec  | 2.52 Gbits/sec  | 93.5 ms
Clouvider       | NYC, NY, US (10G)         | 2.55 Gbits/sec  | 1.90 Gbits/sec  | 70.6 ms
Clouvider       | Dallas, TX, US (10G)      | 1.77 Gbits/sec  | 1.77 Gbits/sec  | 102 ms
Clouvider       | Los Angeles, CA, US (10G) | 1.32 Gbits/sec  | busy            | 143 ms

Geekbench 6 Benchmark Test:
---------------------------------
Test            | Value
                |
Single Core     | 1692
Multi Core      | 3064
Full Test       | https://browser.geekbench.com/v6/cpu/1202347

YABS completed in 8 min 4 sec

Intel Almost dedicated: (CPU from 2020)

curl -sL yabs.sh | bash -s -- -s https://www.vpsbenchmarks.com/yabs/upload
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
#              Yet-Another-Bench-Script              #
#                     v2023-04-23                    #
# https://github.com/masonr/yet-another-bench-script #
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #

Tue May  9 04:38:22 PM UTC 2023

Basic System Information:
---------------------------------
Uptime     : 0 days, 0 hours, 0 minutes
Processor  : Intel Xeon Processor (Cascadelake)
CPU cores  : 2 @ 2992.968 MHz
AES-NI     : âś” Enabled
VM-x/AMD-V : ❌ Disabled
RAM        : 1.9 GiB
Swap       : 5.8 GiB
Disk       : 56.1 GiB
Distro     : Ubuntu 22.04.2 LTS
Kernel     : 5.15.0-71-generic
VM Type    : MICROSOFT
IPv4/IPv6  : âś” Online / âś” Online

IPv6 Network Information:
---------------------------------
ISP        : The Constant Company, LLC
ASN        : AS20473 The Constant Company, LLC
Host       : The Constant Company, LLC
Location   : City of London, England (ENG)
Country    : United Kingdom

fio Disk Speed Tests (Mixed R/W 50/50):
---------------------------------
Block Size | 4k            (IOPS) | 64k           (IOPS)
  ------   | ---            ----  | ----           ----
Read       | 446.37 MB/s (111.5k) | 1.12 GB/s    (17.5k)
Write      | 447.55 MB/s (111.8k) | 1.13 GB/s    (17.6k)
Total      | 893.92 MB/s (223.4k) | 2.25 GB/s    (35.2k)
           |                      |
Block Size | 512k          (IOPS) | 1m            (IOPS)
  ------   | ---            ----  | ----           ----
Read       | 1.08 GB/s     (2.1k) | 853.47 MB/s    (833)
Write      | 1.13 GB/s     (2.2k) | 910.31 MB/s    (888)
Total      | 2.21 GB/s     (4.3k) | 1.76 GB/s     (1.7k)

iperf3 Network Speed Tests (IPv4):
---------------------------------
Provider        | Location (Link)           | Send Speed      | Recv Speed      | Ping
-----           | -----                     | ----            | ----            | ----
Clouvider       | London, UK (10G)          | 8.70 Gbits/sec  | 8.95 Gbits/sec  | 0.710 ms
Scaleway        | Paris, FR (10G)           | busy            | busy            | 8.28 ms
NovoServe       | North Holland, NL (40G)   | 12.2 Gbits/sec  | busy            | 5.83 ms
Uztelecom       | Tashkent, UZ (10G)        | 3.99 Gbits/sec  | 4.87 Gbits/sec  | 98.7 ms
Clouvider       | NYC, NY, US (10G)         | 2.54 Gbits/sec  | 2.36 Gbits/sec  | 71.5 ms
Clouvider       | Dallas, TX, US (10G)      | 1.75 Gbits/sec  | 2.21 Gbits/sec  | 110 ms
Clouvider       | Los Angeles, CA, US (10G) | 1.31 Gbits/sec  | 266 Mbits/sec   | 133 ms

iperf3 Network Speed Tests (IPv6):
---------------------------------
Provider        | Location (Link)           | Send Speed      | Recv Speed      | Ping
-----           | -----                     | ----            | ----            | ----
Clouvider       | London, UK (10G)          | 8.94 Gbits/sec  | 4.20 Gbits/sec  | 0.715 ms
Scaleway        | Paris, FR (10G)           | busy            | 6.21 Gbits/sec  | 7.28 ms
NovoServe       | North Holland, NL (40G)   | busy            | busy            | 5.79 ms
Uztelecom       | Tashkent, UZ (10G)        | busy            | 6.95 Gbits/sec  | 98.7 ms
Clouvider       | NYC, NY, US (10G)         | busy            | busy            | 71.3 ms
Clouvider       | Dallas, TX, US (10G)      | 1.63 Gbits/sec  | busy            | 110 ms
Clouvider       | Los Angeles, CA, US (10G) | busy            | 251 Mbits/sec   | 133 ms

Geekbench 6 Benchmark Test:
---------------------------------
Test            | Value
                |
Single Core     | 1182
Multi Core      | 2123
Full Test       | https://browser.geekbench.com/v6/cpu/1202403

YABS completed in 12 min 18 sec

My own opinion about two VPS above (virtual private servers):

  1. VPS extremely fast
  2. Not overshared
  3. Results can be used as template to compare yours
  4. This is production ready VPS, i.e. some other VPS hosted on the node, and provider balance resources and deliver excellent performance to clients.
  5. I think acceptable and “normal” CPU performance will start with geekbench 6 from 650-700 points.

Perfect, so if we try to make a general guidelines, it would look something like this?

Geekbench 5 Geekbench 6
1000 < 1200 < very good provider
700-1000 900-1200 okay performance
500-700 650-900 normal, can be better
< 500 < 650 awful provider, avoid

Geekbench 6 is heavier then 5

So at least it should be the other way around…

Geekbench 5 Benchmark Test:

Test | Value
|
Single Core | 530
Multi Core | 984
Full Test | Hetzner vServer - Geekbench Browser

Geekbench 6 Benchmark Test:

Test | Value
|
Single Core | 664
Multi Core | 1161
Full Test | Hetzner vServer - Geekbench Browser

Would not expect that …