Initial Server Response on a simple "Hello World" PHP file behaving erratically.

bluesteam

Verified User
Joined
Jan 28, 2021
Messages
66
Hello,

Firstly, some technicals out of the way:

VPS Hardware Specs:
Cores:
4
RAM: 8GB
Storage: 250GB

Software Specs:
DirecAdmin Version:
1.61.5
CustomBuild Version: 2.0.0 (rev: 2720)
CloudLinux:
PHP Version: 7.2 (Client can't upgrade at this time) (Memcache & OPCache both enabled)
Apache Version: 2.4.48
MySQL Version: 5.7.33

This is just a request for some guidance and advice.

I am trying to reduce the Initial Server Response time down to as low as possible so that once we have that down, my clients cannot complain about the hardware/OS/DB/PHP/WebServer being the problem anymore.

I have a situation where a client has asked that I investigate the TTFB of the VPS server that I have provided him. Looking at Google Page Insights scan, it says that the initial response time of the server can be improved. Google says the initial response is 1970ms I have investigated everything I could to see how to bring this value down but cannot think of what else I can do. :(

https://developers.google.com/speed/pagespeed/insights/?url=https://www.performanceproducts.co.za

1623047640041.png


To eliminate any unnecessary load on the server response such as themes or database queries etc, I created a simple php file with only Hellow World! in it to test the simple response time to see what I would get.

Code in simple file:
PHP:
<?php echo "Hello World!" ?>

Google Page Insights states that this simple file took 670ms to load. Repeated tests vary and show sometimes a full 1s to load. Other times it is below 400ms but never lowe. This is not impressive from my point of view and I am not sure what to do here to fix this.

https://developers.google.com/speed/pagespeed/insights/?url=https://performanceproducts.co.za/ttfbtest.php
1623048700892.png




VERY interestingly, testing another domain (coolboostsystems.com) on the same account shows a MUCH slower response time on the same file and yet both domains are running PHP 7.2 and all the same extensions etc. and on the same account.

https://developers.google.com/speed/pagespeed/insights/?url=https://www.coolboostsystems.com/ttfbtest.php
1623048996383.png


1. What illusions am I under here that is skewing my thinking?
2. What can be done if anything to improve this WITHOUT moving to a different provider?
3. Why are the two domains so vastly different in response times when the same file is executed from the same DA account.

Can anything be done here?

Looking forward to your replies :)
 
Last edited:
Firstly, some technicals out of the way:

VPS Hardware Specs:
Cores:
4
RAM: 8GB
Storage: 250GB

Software Specs:
DirecAdmin Version:
1.61.5
CustomBuild Version: 2.0.0 (rev: 2720)
CloudLinux:
PHP Version: 7.2 (Client can't upgrade at this time) (Memcache & OPCache both enabled)
Apache Version: 2.4.48
MySQL Version: 5.7.33
Bravo thank you for giving details.
I investigate the TTFB of the VPS server that I have provided him.
Is it a Managed server? Just curious.

Mysql
Did you optimize the /etc/my.cnf for the mysql server?
How much RAM did you dedicate to the server within the cnf file?

HTTP
Are you on MPM event?
Did you tweak the conf for memory use

PHP
I assume php-fpm
Did you tweak the PM defaults based on RAM use?
Is Opcache tweaked as well?
 
Is it a Managed server? Just curious.
It's a Self-Managed Server. None of the local providers offer Managed servers at a reasonable price so I have to do it myself.

Mysql
"Did you optimize the /etc/my.cnf for the mysql server?"
Haven't touched the file at all.

"How much RAM did you dedicate to the server within the cnf file?"
Stock Standard from DA. No changes made

HTTP
"Are you on MPM event?"
Where do I check this on DA? Again, stock standard DA install.

"Did you tweak the conf for memory use"
No, What do I look for exactly to know what to tweak and where?

PHP
"I assume php-fpm"
If the DA uses php-fpm as default then yes it's php-fpm

"Did you tweak the PM defaults based on RAM use?"
Again, sorry for not knowing where to look for this but no.

"Is Opcache tweaked as well?"
No, it's stock standard. What changes should be made?


This might make me sound like an amateur but to be honest, I figured that DA should be optimised right out of the gate but that is obviously a naive sentiment!

I really appreciate you answering me here. I really do as i am a bit at a loss!
 
I figured that DA should be optimised right out of the gate
No Is standard setup. Defaults for the masses. Not tweaked for preformance.
I have to do it myself.
Sorry I assumed you were the Provider not a customer(user).
I really appreciate you answering me here. I really do as i am a bit at a loss!
No Problem
I am helping a guy in UK currently here. https://forum.directadmin.com/threads/slow-image-loading-speeds.63794/post-331518

Some of it might help you. He has more RAM than you so the config would have to be changed.

I could help you do you understand ssh and the command line?
 
No Is standard setup. Defaults for the masses. Not tweaked for preformance.

Sorry I assumed you were the Provider not a customer(user).
Well, I've only ever offered shared hosting to my clients. This server would be my first so it is quite the adventure.

I could help you do you understand ssh and the command line?
definitely do. ? I wouldn't say I'm an expert but definitely not a beginner.
 
You use cloudlinux i see. What does lsphp give? (I'ts highly recomended to use lsphp with cloudlinux, aperantly)
 
You use cloudlinux i see. What does lsphp give? (I'ts highly recomended to use lsphp with cloudlinux, aperantly)
As far as I know, LSPHP is only compiled when running LiteSpeed web server. We aren't using LiteSpeed.
 
Logging in as root or admin and simply running lsphp command yields nothing. It just sits there. doesn't even go back to the command prompt. I have to CTRL-C to get back to the command line.

The command seems to be working though because simply entering lsphp --help yields the helps tips.

[admin@##### ~]$ lsphp --help
Usage: php
php -[b|c|n|h|i|q|s|v|?] [<file>] [args...]
Run in LSAPI mode, only '-b', '-s' and '-c' are effective
Run in Command Line Interpreter mode when parameters are specified

-b <address:port>|<port> Bind Path for external LSAPI Server mode
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-h This help
-i PHP information
-l Syntax check
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-? This help

args... Arguments passed to script.
[admin@###### ~]$
 
just to make sure:
did you rebuild php too so it takes effect (./build php n)

after that you should just test your site again. (and run phpinfo() in a script to verify you're using lsphp)
 
well, this is a standard install and seeing it there as the first option I thought it was enabled when the first php1_mode was lsphp but clearly I was wrong.

I ran the phpinfo to check and after searching the word lsphp, I can't see anything in there.

I have PM'd you a link to my PHPinfo so you can confirm from your side if my findings are correct.
 
Mysql lets try this.

ok in the /etc/my.cnf
Code:
Code:
nano /etc/my.cnf
Make it look like this. Note: put your server fqdn where it shows "server.domainname.com"
Code:
Code:
[mysqld]
#local values
local-infile=0
#skip-name-resolve=1
#log-error=/usr/local/mysql/data/server.domainname.com.err
bind-address = 127.0.0.1
max_allowed_packet=64MB
#max_connections=25
wait_timeout=100

#innodb values
innodb_log_file_size=512MB #25% of Buffer pool
innodb_file_per_table
innodb_buffer_pool_size=4G # 50% of memory
innodb_buffer_pool_instances=4 #1 per GB


#temp values
tmpdir=/tmp
join_buffer_size=256k
table_definition_cache=1000
thread_cache_size=1000
then restart mariaDB with
Code:
Code:
systemctl restart mariadb
systemctl status mariadb
OR
systemctl restart mysqld
systemctl status mysqld
 
What does
Code:
php -v
httpd -V | grep 'MPM'
give
 
Last edited:
Mysql lets try this.

ok in the /etc/my.cnf
Code:
Code:
nano /etc/my.cnf
Make it look like this. Note: put your server fqdn where it shows "server.domainname.com"
Code:
Code:
[mysqld]
#local values
local-infile=0
#skip-name-resolve=1
#log-error=/usr/local/mysql/data/server.domainname.com.err
bind-address = 127.0.0.1
max_allowed_packet=64MB
#max_connections=25
wait_timeout=100

#innodb values
innodb_log_file_size=512MB #25% of Buffer pool
innodb_file_per_table
innodb_buffer_pool_size=4G # 50% of memory
innodb_buffer_pool_instances=4 #1 per GB


#temp values
tmpdir=/tmp
join_buffer_size=256k
table_definition_cache=1000
thread_cache_size=1000
then restart mariaDB with
Code:
Code:
systemctl restart mariadb
systemctl status mariadb
OR
systemctl restart mysqld
systemctl status mysqld

Does this still apply if we are running MySQL and not MariaDB?

What does
Code:
php -v
httpd -V | grep 'MPM'
give

[root@***** /]# php -v
PHP 7.4.20 (cli) (built: Jun 17 2021 13:01:33) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
[root@***** /]# httpd -V | grep 'MPM'
Server MPM: worker
[root@***** /]#
 
Hey Brent :)

in options file what is the webserver? Apache or some form of Litespeed?

You mentioned an options file. Where is this file located so that I can make sure I give you the exact info needed. As far as I know, it is Apache. We haven't installed LiteSpeed at all.


yes try it. Let me know what happens.
Will do and revert back
 
Back
Top