TTFB avarage 1 to 1.3 sec

bcx

Verified User
Joined
Dec 11, 2015
Messages
77
I'm building a new wordpress on a dedicated server with OpenLiteSpeed.
At the moment it has 113 requests. Page size is 1.6 mb
Load time 2.99 seconds


Php 7.4 lsphp 7.4.32

Fujitsu PRIMERGY RX1330 M4
CPU: Intel Xeon E-2236
Memory: 32GB ECC DDR4 RAM
Storage: 2x 500GB NVMe SSD Software RAID-1
OS: Debian 11.x (bullseye)


I was recently able to rent the above server, but still, the TTFB is high, and now I want to find out what is causing this.

For example
1668865875009.png

Reduce initial server response time

1.13 s

Keep the server response time for the main document short because all other requests depend on it. Learn more. FCPLCP
Themes, plugins, and server specifications all contribute to server response time. Consider finding a more optimized theme, carefully selecting an optimization plugin, and/or upgrading your server.


Learn more says:

WordPress #

Themes, plugins, and server specifications all contribute to server response time. Consider finding a more optimized theme, carefully selecting an optimization plugin, and/or upgrading your server.



-----
Are their any server side settings that I need to consider to check out, that could help with the TTFB?

GTmatrix says:

Root document took 1.2s


Thank you in advance.
 
Last edited:
If you haven't installed the LightSpeed Wordpress plugin, it would be a good idea. If not, use a cache plugin, say W3 Total Cache is decent. What ever one you use, make sure you configure it after installing it to actually get the full benefit out of it.

Also if your getting that long a page load time, I would review how many and what kinds of plugins your using. Some can cause serious performance issues, one example is page builders or Woocommerce.

Would also be a good idea to enable opcache, and configure it. I have mine configured like this (default doesn't seem to be enough for most WordPress installs anymore):

Code:
opcache.memory_consumption=512
opcache.max_accelerated_files=16000

Also make sure you have enough memory allocated for php.

Set a .user.ini in web root to increase memory_limit=512M

May need to add this to WordPress config file:
Code:
define('WP_MEMORY_LIMIT', '512M');

If your also running Woocommerce may need to increase the memory a bit more.

Also wouldn't hurt to check MYSQLTuner to see if database needs some optimization.

As a last note make sure your swapiness is set (mine i set to 1), check your ram usage. Remember making these types of changes will use more ram, so if your low on available ram that will need to be fixed first.
 
How far is the server from the test site you're using? My server is in the US and I average less than 200ms in the US. In Asia, I average 750ms. In Europe it's 425ms.

GTMetrix tells me

Root document took 53ms

I have openlitespeed, redis, litespeed plugin on wordpress - and a much smaller server than you have...
 
How far is the server from the test site you're using? My server is in the US and I average less than 200ms in the US. In Asia, I average 750ms. In Europe it's 425ms.

GTMetrix tells me

Root document took 53ms

I have openlitespeed, redis, litespeed plugin on wordpress - and a much smaller server than you have...

Thank you Both for your input.

So far it got this result!

Before 1.61 second after 0.10 second 94% improved
Page score 47 after 98 improved by 52%

This on a pretty heavy site, with two youtube videos in the bg and over 400 request on the homepage (yeah elementor :) ).
So I think thats great job, for only the litespeed plugin so far..

Also the tip for WP LIMIT 512M did a lot @cjd so thank you.

opcache is not installed yet, in the PHP extensions settings it still set to no.
So i put this setting to YES in the CustomBuild 2 options, but I don't see any changes in the dash where i can put those numbers in? I'm a bit confused.

opcache.memory_consumption=512
opcache.max_accelerated_files=16000

Now on a subdomain i would like to run a woocommerce with the user db and roles in sync. This last part is already done.
However I thought woocommerce was telling something about object cache when i installed it, but i can't find that message anymore with install instructions for your server.

Now I read tons of things about memcached and redis. But not sure what to install. @BillyS You're running on Redis, why did you go for this one?

My server is hosted in the Netherlands.
On gtmetrix - canada i get TTFB 315 ms - Time to interact is 1.9 sec
Londen unable to test today, as i run out of free tests. Will post it later.
 
For opcache I create a 99-custom.ini with the above lines you quoted (and some time some more settings) placed in the /usr/local/php74/lib/php.conf.d/ directory (I put it in all my installed versions of php's config directory's). After setting php opcache setting in custom build you need to build the plugin, you can do it in the web interface or ssh in and do a:
Code:
cd /usr/local/directadmin/custombuild
 ./build php_opcache
 
For opcache I create a 99-custom.ini with the above lines you quoted (and some time some more settings) placed in the /usr/local/php74/lib/php.conf.d/ directory (I put it in all my installed versions of php's config directory's). After setting php opcache setting in custom build you need to build the plugin, you can do it in the web interface or ssh in and do a:
Code:
cd /usr/local/directadmin/custombuild
 ./build php_opcache
And in the plugin you can set the 99-custom.ini file ?
It's not recommended to place it inside the usr/local/php74/lib/php.ini itself?
 
I place my changes in it's own file so that it doesn't get modified by any updates.

If you look in that directory there is also a 10-directadmin.ini which has the default values, which adding 99-custom.ini file last overrides the values.
 
I will look into this, this is new for me how to create those file. Will search some guidelines. Thank you CJD for the tips and tricks.
ps: once this is done. How do you notice or see that opcache is working?
 
Everything in stored in memory, you should see a performance increase almost right away when logged in the WP admin back-end.

If you want to actually see it's working you can use this tool:


Just put it in a sub folder on the site and point your web browser to it and it should give you some stats of opcache performance.
 
  • Like
Reactions: bcx
So far i remember opCache memory is multiplicated with the amount of users, so dont set it too high. It doesnt need so much, mostly 192 or 256 should be enough. Let it run a few days and check it with the GUI, then set opcache memory according to that.
 
Yes, always have to make sure the server has enough memory for what you want to do. I did a quick check across a bunch of sites/servers, I have opcache memory usage ranging from 102MB to 490MB from the ones I checked. So it can add up quickly. If the sites are light, as mentioned, reduce the memory for the cache to save memory.
 
@BillyS You're running on Redis, why did you go for this one?
I didn't pick Redis over Memcached for any other reason that the DA version I have supports Redis natively. If you're using Openlitespeed with WordPress and the litespeed cache plug in, then you can select either.
 
for customize opcache setting, I suggest to use this tutorial
 
Yes, always have to make sure the server has enough memory for what you want to do. I did a quick check across a bunch of sites/servers, I have opcache memory usage ranging from 102MB to 490MB from the ones I checked. So it can add up quickly. If the sites are light, as mentioned, reduce the memory for the cache to save memory.
My server has 32 GB so still only set it to 124 - 265 or max 512 mb ?

@jamgames2 thanks for the tutorial I will follow that one
 
256 will probably be fine for most sites. (DA default is 128)

For the files DA's default is 4000, which most of my servers went over, max was about ~10000 on a few sites (this is just from doing a quick random sampling of 'normal' sites), I would probably set it at a minimum of 8000 for the files as that met the majority of sites just fine (i have mine at 16000)

Most of the servers I manage have 64-96GB of ram, so i'm usually a little more generous with the numbers.

Either method of modifying the configuration should work fine, i'm just used to doing it the 'old' way. Both methods will survive updates, the recommend tutorial will automatically work with even added new php versions, old way needs to be added manually to new php versions.
 
Back
Top