My experiences on page speed
Hello everybody for the last 2 weeks I was dealing with some tweaks to increase UNA page speed. I would like to share my experiences, for the non professionals it may answer some frequent questions.
Web Server & PHP
I tested 3 web servers in this period APACHE, NGINX, LITESPEED
PHP was 7.2 in all variants.
The tested identical Homepage has timelinemany pictures videos etc. it is full as can be. cache setting is closed from developer >pages>homepage>settings>cache =0
test server is 1 GB 1 vCPU
PHP 7.1 was faster then 7.2,
but there were possible setting problems with images. (From studio use GD library did the trick for php7.1)
PHP 7.3 doesnt have the XML module in the repository, it doesnt work properly with UNA yet.
With mod-php it is the slowest, with php-fpm faster, it uses .htaccess files for directory specific settings. memory consumption is quite high with mod-php.
homepage with timeline reload (F5) with mod-pgp 24 seconds, second load with clicking to homepage link 18 seconds
didnt test apache with php-fpm @Baloo may have an idea on it.
Well known for being faster and lighter.
It uses php-fpm, doesnt use .htaccess files,
modrewrite syntax is a little different you have to translate them to NGINX style.
Memory and CPU consumption dropped drastically.
If you do correct settings to opcache it will show its positive effect.
homepage with timeline reload (F5) with php-fpm15 seconds, second load with clicking to homepage link 9,3 seconds
This is a new web server comparing to Apache or NGINX.
It can use the apache conf files and .htaccess files.
Apache compatible. Uses its own php fpm.
(there is a openlitespeed free version but this doesnt have apache compability.)
İt has a free enterprise version for servers up to 2 GB, I tested with this one.
it complies different php versions, needs a bit of learning the admin interface.
homepage with timeline reload (F5) with 12 seconds, second load with clicking to homepage link 6,2 seconds, quite impressive.
The first surprising result for the hardware was a 1 GB 1 vCPU server may open UNA pages faster then a 32 GB 8 vCPU server. I know unbelievable but this was what I got on Digital Ocean servers.
This was mind blowing, I tested again and again with different servers same results...
Then I started to research...
I found that php is not multitreated! It has somehow multireading for the cgi mode only.
So many vCPU is not benefiting php, it uses one of them for a certain connection.
And when I checked the vCPU cores it was solved.
The CPU frequency was almost same but the only difference was:
in the 1 vCPU server the L2 cache is 1 MB, while in the multiCPU ones it was only 256 KB.
So as PHP is using only one core, that one with 1 MB L2 cache beats all others alone :)
Though more memory and CPU may help for more instant traffic and mysql part.
MYSQL => Mariadb
Mysql uses more resources then php and web server especially CPU on a php-fpm setting.
Making the correct cache settings is important. Read from reliable sources and apply.
First thing first I replace mysql with mariadb.
Most important values are
innodb_buffer_pool_size = to be ~70 % of total memory
key_buffer = not very sure but to be ~1/8-1/4 of innodb_buffer_pool_size gives good results
While checking things with mysqltuner I noticed that inno caches are not used at all.
I disabled inno:
skip-innodb or innodb = off
comment all innodb settings
selected Aria (advanced version of MyIsam) as the default db engine reorginize the settings.
homepage with timeline reload (F5) with 11,7 seconds, second load with clicking to homepage link 7,18 seconds
SEPERATE MYSQL SERVER SCENARİO
To see how will be the seperate mysql server I used the same 1 GB 1 vCPU servers one like above and one with only mysql.
In this scenario yes CPU and memory usage dropped, but the private network between servers was the bottleneck.
homepage with timeline reload (F5) with 25 seconds, second load with clicking to homepage link 18 seconds. For the slow network issue I have a ticket and waiting the answer. I will update here.
It is seen that the network connection is not the problem but the settings in php and mysql is important.
time mysql -h 10.133.78.242 -u'una' -p'XXXX' -e'show status'
real 0m 0.073s
user 0m 0.011s
sys 0m 0.003s
After doing the above mentioned changes on Mariadb like disabling innodb completely, I got 13 seconds from timeline instead of 18.
I dont have an idea if disabling innodb is suitable for una or not??? LeonidS
Of course if you dont want to deal with all these, you have the UNA ready hosting from boonex and no worries :)
If you have any questions about my tests please feel free to ask here. But I have to mention that I am not a professional I will try answer within the limits of my knowledge and small experience.