Hosting – WP Speed Matters https://wpspeedmatters.com Thu, 03 Feb 2022 02:48:14 +0000 en-US hourly 1 https://wordpress.org/?v=6.2.2 https://wpspeedmatters.com/wp-content/uploads/2019/07/favicon-50x48.png Hosting – WP Speed Matters https://wpspeedmatters.com 32 32 DigitalOcean Premium vs Vultr High Frequency Performance https://wpspeedmatters.com/digitalocean-premium-vs-vultr-high-frequency/ https://wpspeedmatters.com/digitalocean-premium-vs-vultr-high-frequency/#comments Sun, 14 Mar 2021 07:36:25 +0000 https://wpspeedmatters.com/?p=3922 Vultr has a “High Frequency Compute” VPS that has high clock speed and NVMe. It has some excellent performance!

DigitalOcean also recently introduced a similar VPS called “Premium Droplets” powered by Intel and AMD with NVMe SSDs.

So I decided to compare the performance of both with WordPress!

Testing Setup

I created 5 VPS servers in the same region as follows:

  • DigitalOcean Regular – $5/month
  • DigitalOcean Premium Intel – $6/month
  • DigitalOcean Premium AMD – $6/month
  • Vultr Regular – $5/month
  • Vultr High Frequency – $6/month
Screenshot 2021 03 14 at 12.01.05 PM

Running performance test via Google PageSpeed Insights or GTmetrix is not an ideal way to test servers’ performance as it can vary based on several factors.

So I used loader.io to send requests from 0 to 500 clients per second over 1 min.

Screenshot 2021 03 14 at 12.07.38 PM

Test Results

DigitalOcean Regular
DO Intel Regular
DigitalOcean Intel Premium
DO Intel Premium
DigitalOcean AMD Premium
DO AMD Premium
Vultr Regular
Vultr Regular
Vultr High Frequency
Vultr HF

Summary

VPSAverage Response Time
DigitalOcean Regular5.9s
DigitalOcean Intel Premium5.2s
DigitalOcean AMD Premium3.7s
Vultr Regular7.0s
Vultr High Frequency3.1s
DO vs Vultr

Conclusion

Vultr High Frequency has the best performance of all. DigitalOcean AMD Premium is also close.

If I had to choose between these, I would probably go with DigitalOcean AMD Premium as I’ve seen better uptime with DigitalOcean than Vultr.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/digitalocean-premium-vs-vultr-high-frequency/feed/ 11
How to Speed up HTTP to HTTPS Redirection in WordPress https://wpspeedmatters.com/http-to-https-redirection/ https://wpspeedmatters.com/http-to-https-redirection/#comments Sat, 27 Jun 2020 03:08:59 +0000 https://wpspeedmatters.com/?p=3674 If most of your visitors are from Google (organic) or social media sites, most probably they are directly visiting the HTTPS version.

But what if there are visitors who directly visit your site entering the domain in the browser?

In my case, I usually type “wps”, Chrome suggests “wpspeedmatters.com” and I press enter.

Browser by default sends the request to “http://wpspeedmatters.com” and later redirects to “https://wpspeedmatters.com”.

Why HTTP to HTTPS is slow?

If you’ve set up https in your WordPress settings, then WP will take care of the redirection.

But it will be done by PHP.

Depending on your hosting provider and load, redirection via PHP can be slow. It’s better to offload it from PHP.

Step1: Configure Web Server for HTTPS redirection

Configuring web server like Nginx/Apache/LiteSpeed to do the redirection will be always faster than PHP.

Apache/LiteSpeed

If you’ve Apache/LiteSpeed web server, add the following code to .htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Nginx

In Nginx, add the following config:

server {
  listen 80;
  server_name domain.com www.domain.com;
  return 301 https://domain.com$request_uri;
}

Cloudflare

If you’re using Cloudflare, things are much easy. Go to SSL/TLS settings -> Edge Certificates and enable ‘Always Use HTTPS’.

image 2

Optionally, enable ‘Automatic HTTPS Rewrites’.

image 3

Additional Tip

You can also add a meta tag to tell the browser to use HTTPS for all requests inside a page.

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

Step 2: Enable HSTS

HSTS or HTTP Strict Transport Security is a response header.

In simple words, this tells the browser “hey, this website will have HTTPS for X no. days, so use HTTPS by default”.

So next time when someone enters “wpspeedmatters.com” or “http://wpspeedmatters.com”, browser directly opens “https://wpspeedmatters.com”.

HSTS has some security benefits too, MitM attack (Man in the Middle attack).

Apache/LiteSpeed

Add the following code to .htaccess file:

<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
</IfModule>

Nginx

In Nginx, add the following config:

server {
    listen 443 ssl;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}

Cloudflare

Under SSL/TLS settings -> Edge Certificates and Enable HSTS.

image 4

Configure it as below:

image 5

Verify HSTS

You can check if it’s working or not by checking the response header:

image

You can also visit https://hstspreload.org/ to check the same.

Step 3: Submit to Chrome HSTS List

Even if you’ve enabled HSTS, the user visiting your site for the first time will have HTTP to HTTPS redirection.

But Chrome maintains a list of HSTS enabled sites hardcoded in the browser (other browsers also use this list). So if your site is added to that list, no more redirection!

Go to https://hstspreload.org/ and submit your domain.

image 6

Conclusion

I’ve often seen redirection take ~1s in some shared hosting providers. This can affect your FCP, FMP etc.

We often test HTTPS version in testing tools like GTmetrix, Google PageSpeed Insights. But users who directly visiting our site may be from HTTP.

In my case, ~30% of the visitors are ‘direct’.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/http-to-https-redirection/feed/ 3
Closte.com Review – The Hidden Gem in WordPress Hosting https://wpspeedmatters.com/closte-wordpress-hosting-review/ https://wpspeedmatters.com/closte-wordpress-hosting-review/#comments Wed, 05 Feb 2020 05:08:44 +0000 https://wpspeedmatters.com/?p=3375 I thought Kinsta was the best WordPress hosting provider, both in terms of performance and features. But Closte changed my mind.

I’ve been using Closte for more than an year now and I’m pleased with it.

This post is an honest review from a happy customer. I’m not affiliated to Closte.com.

What is Closte.com?

closte dashboard

Closte.com is a managed WordPress hosting platform. What makes them different from others is mainly the performance.

Closte sites

Features

Just like you see in a managed WordPress hosting provider, you’ve all the basic features you need:

  • Google Cloud servers
  • Google CDN
  • LiteSpeed webserver
  • Staging environment
  • Backups
  • Collaboration
  • Free SSL
  • Free migrations
  • SSH, FTP, git, WP-CLI, logs, phpMyAdmin etc

But Closte has some features that some others don’t provide or they do it really well.

Here are they:

LiteSpeed Webserver

There are only a few hosting providers that provide LiteSpeed.

LiteSpeed is a pretty new webserver (an alternative to Apache and Nginx). Some of the significant advantages are performance and the free LiteSpeed cache plugin. There are plenty more.

PS: OpenLiteSpeed is the open-source version of LiteSpeed.

CloudSnap and Backups

I don’t manage any external backups when I’m in Closte.

I would say Closte has two levels of backups. One is usual incremental backups (automated and manual), and another one is CloudSnap.

CloudSnap is like a snapshot of the whole site. You can easily create a new website from the CloudSnap backup. It’s a kind of blueprint!

I’ve got a few CloudSnaps like “Elementor”, “WooCommerce”, “Blog”, etc. So whenever I need to test something with these, I just create a new website from these snapshots. It’s handy for me as a plugin developer.

CloudSnaps Closte

Closte also has distributed and disaster backups.

Security

Ever since I moved to Closte, I’ve never received spam via contact form submission or a brute force attack or any such security threats. I also don’t use any security plugins.

Closte has some inbuilt security features like real-time malware detection, DDOS, WAF etc.

closte security

Google CDN

There are many managed WordPress hosting providers and controls panels that let you run your site in Google Cloud. But none of that has Google CDN integration.

Fastest CDN

What’s so special about Google CDN? It’s the fastest of all (source: cdnperf.com).

CDNperf Google CDN

Cache-to-Cache Fill

Google CDN also has a cache-to-cache fill feature, which means if an edge server doesn’t have the file requested, it will try to serve from a nearby edge server. This increases cache hit ratio and reduce requests to the origin.

Staging Sites 

Unlimited Staging Sites

Almost all managed hosting providers provide a staging environment. However, in Closte, you can create unlimited staging sites for the same site.

No Resource Limits

Also unlike other providers, resources are not limited in staging. You get full power as in the live environment. This is something I really hate in Kinsta and WP Engine.

CDN in Staging

You also get CDN for the staging sites too. Comes in handy when you’re doing speed optimizations in a staging site.

Pricing

Unlike other hosting providers, Closte doesn’t have a fixed price or plans. It’s a pay-as-you-go model.

So the monthly cost of a website varies based on several factors like:

  • CPU and memory (RAM) usage (includes staging site)
  • No. HTTP requests
  • Bandwidth usage
  • Disk usage
  • CloudSnap disk usage
  • CDN bandwidth usage (varies based on location)

This makes it extremely difficult to predict the pricing.

A good method is to host with them for a minimum of 1 month and see how much you’re charged.

There are some advantages to the pay-as-you-go model. If your site has low traffic in a month, you’re charged less.

Also, to test different things while developing plugins, some days my account may have 10 live sites and in some days it’s just 2 or 3. If I’m in Kinsta or WP Engine, I’ve to pick a plan that supports up to 10 sites.

No such issues in Closte!

Pricing of a few sites I worked with

Here is the pricing of a few sites that I’ve worked with, from my clients/friends:

Type of siteMonthly pageviewsPricing
Site #1Blog30k$9/month
Site #2Product portfolio17k$11/month
Site #3Blog670k$50/month

As you may have noticed, predicting cost based on pageviews is also very difficult.

Site #3 was previously using Kinsta and they were charging him $200/month. After moving to Closte, he’s only charged $50/month.

Tips to Reduce Cost in Closte

  • Use a full page caching plugin – Usually memory and CPU consumes ~50% of the total cost. Using a full page cache plugin like FlyingPress can reduce memory and CPU usage dramatically.
  • Use an external CDN – Google CDN is extremely fast, extremely costly too. It takes a good percentage of the overall cost. Use an external CDN provider like BunnyCDN which is almost 10 times cheaper than Google CDN.
  • Delete staging site when not in use – As I said before, Closte charges based on usage. Even if you’ve no visitors to your staging site, it will consume CPU and memory. So delete the staging site when not in use.

Support

This is something Closte lacks.

They don’t have live chat support. Only support tickets and it may take 24-48 hours to get a response.

For me or anyone a bit technical, this won’t be an issue. All my clients, including myself, are pretty happy with their support.

I’ve also heard a few feedbacks saying that their support is rude.

From one of my tickets:

closte support

I didn’t like their reply “You don’t have any benefits”. They could be a little more friendly and polite. I replied to them with the detailed features and bug fixes in v5.3.

Kinsta vs Closte support

Kinsta is very well known for its award-winning 24×7 support. Yes, they’re really good at it.

However in Kinsta, while optimizing my clients’ sites, I occasionally had to contact them for changing Nginx config, increasing PHP workers limit, some issues with their inbuilt Nginx caching, increasing resources in staging etc.

kinsta support
Talking to Kinsta support for enabling WebP

However, in Closte, I’ve never run into such issues.

Everything works out of the box, their platform is so stable. Most of my supports tickets are either suggestions or “when will feature X be ready”.

Also thanks to the LiteSpeed server, I never had to deal with Nginx configs!

Performance

I’ve tested almost all managed hosting providers like Kinsta, WP Engine, Cloudways, SiteGround, etc and control panels like RunCloud, CyberPanel, GridPane with VPS from popular Cloud providers like Googe Cloud, Vultr, Linode, DigitialOcean etc.

From what I’ve tested so far, I haven’t seen anything which has better performance than Closte. Thanks to their super tech stack with Google Cloud, Google CDN, LiteSpeed server etc.

Uptime

I’ve got 100% uptime since I migrated to Closte.

Report from UptimeRobot:

uptimerobot closte

Final Thoughts

I really really like Closte. Using it for 7 months till now and will continue.

However, I don’t recommend it to everyone. Two reasons – Support and Pricing.

If you’re not really that technical and need live chat support 24×7, then Closte may not be the right choice for you.

Similarly, Closte is not cheap. Even if your site has very low traffic, Closte will have a minimum charge. Also, if you’re are an agency or developer, it’s extremely hard to tell your clients how much it will cost.

If you want similar performance, with all good features, predictable pricing, good support, I highly recommend Cloudways hosting (along with FlyingPress and BunnyCDN). A $10/month or $20/month plan would be enough to host multiple high-performance sites.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/closte-wordpress-hosting-review/feed/ 24
5 Reasons on Why I Prefer OpenLiteSpeed over Nginx in WordPress https://wpspeedmatters.com/openlitespeed-over-nginx-in-wordpress/ https://wpspeedmatters.com/openlitespeed-over-nginx-in-wordpress/#comments Wed, 04 Sep 2019 06:17:59 +0000 https://wpspeedmatters.com/?p=2220 Few months I started to migrate all my sites to OpenLiteSpeed. Also migrated a few clients to OpenLiteSpeed and LiteSpeed enterprise. Performance is one of the main reason.

But not just performance, there are many more factors on why I prefer OpenLiteSpeed over Nginx.

Here are they:

High Performance by default

I did some detailed testing on OpenLiteSpeed vs Nginx before. You can see the results here:

OpenLiteSpeed wins in terms in TTFB (time to first byte) and the number of concurrent users it can handle. Very handy if you’re running multiple sites in a single server.

An expert can configure Nginx to max out the performance with FastCGI. There are also some well-optimized versions of Nginx with LEMP stack like CentminMod.

openlitespeed vs

OpenLiteSpeed/LiteSpeed can also be configured similarly. However, I found that OpenLiteSpeed performs well, especially with their inbuilt LS cache when compared to Nginx by default.

Lower Server Costs

Both LiteSpeed and OpenLiteSpeed have an event-driven architecture which uses far less memory (RAM) and CPU when compared to Nginx and Apache.

I recently had a client running on Nginx VPS paying $80/month, which I migrated to OpenLiteSpeed VPS were $60/month was enough. It saved him $20/month.

Here is the usage of Nginx and OpenLiteSpeed server running a WooCommerce WordPress site:

nginx usage
Nginx Resource Usage
openlitespeed usage
OpenLiteSpeed Resource Usage

To summarize, here is the average resource usage of both:

NginxOpenLiteSpeed
CPU Usage2.0%0.3%
Memory Usage41%29%

Free Powerful Cache Plugin

What if I say you don’t need to buy any paid cache plugins if you’re in LiteSpeed/OpenLitespeed?!

LiteSpeed Technologies have developed their own cache plugin that works well with LiteSpeed and OpenLiteSpeed server. Feature-wise, it competes with paid cache plugins like WP Rocket and Swift Performance.

litespeed cache
LiteSpeed Cache
litespeed cache comparison

OpenLiteSpeed cache module is built right into the web server and uses a tag-based caching (which is smarter in purging than Nginx FastCGI).

Unlike other cache plugins, LiteSpeed cache is actively maintained. There is no other web server company that has this much tight integration with WordPress!

litespeed cache changelog
LiteSpeed Cache changelog

Understand Apache Rewrite Rules

LiteSpeed is built as a drop-in replacement to Apache server. Both LiteSpeed and OpenLiteSpeed can understand .htaccess file in your directory and work accordingly.

One of the biggest nightmares with Nginx in the configuration file. No single Nginx config fits for everyone. Cache plugins, plugins like WebP Express requires to modify Nginx config to make it work.

For me, this is a big win since I don’t have to manually ssh into the server and edit Nginx config (which is a very risky job for me!).

htaccess litespeed cache

Security

There is no doubt that Nginx can be configured to get the best security. But both LiteSpeed and OpenLiteSpeed have some security features that are built-in and doesn’t require much configuration. DDOS prevention with reCaptcha is one of my favourites.

openlitespeed vs litespeed security

But why premium hosting companies like Kinsta, WP Engine uses Nginx?

LiteSpeed Technologies released the initial version of LiteSpeed (enterprise version) in 2003, almost the same year when Nginx was released. But why LiteSpeed didn’t get traction?

LiteSpeed started to gain traction after the release of OpenLiteSpeed (the open-source version of LiteSpeed) which is released in 2015. WordPress community started to look into it after the release of LiteSpeed cache plugin in 2016.

Kinsta and WP Engine were established in 2013 and 2010 respectively. They’ve their own caching layers, plugins, logging, tools, SSL certificates that are entirely built based on Nginx. It will be too much work for them to migrate to OpenLiteSpeed.

Conclusion

Good hosting is still one of the biggest struggles for OpenLiteSpeed. Closte is good, but their pricing and support aren’t great.

New managed WordPress hosting providers that use OpenLiteSpeed are on the way. CyberPanel is also a good control panel if you’re ok with managing server yourself.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/openlitespeed-over-nginx-in-wordpress/feed/ 20
How I Benchmark WordPress Hosting Providers https://wpspeedmatters.com/benchmark-wordpress-hosting/ https://wpspeedmatters.com/benchmark-wordpress-hosting/#respond Fri, 30 Aug 2019 06:47:34 +0000 https://wpspeedmatters.com/?p=2217 I usually change hosting every 2 months, just to see how everyone performs. Every time I switch to a new hosting, I’ll run a few tests to see how it performs.

4 Pillars of Performance

Here are the important factors that you need to measure on choosing a hosting provider:

  1. Networking
  2. Server Hardware
  3. Handling Load
  4. Consistent Performance

Measure Networking

Measuring TTFB is a good way to test your hosting provider’s networking, caching functionality, server response time etc.

A good hosting/server should respond within 100ms if the server and test location (audience) is in the same region. Google and others recommend having a TTFB of less than 300ms worldwide.

How to measure TTFB

Several tools like GTmetrix, Pingdom, Google PageSpeed Insights can measure TTFB. But my favourite one is KeyCDN TTFB Test tool. It will test the TTFB from 14 locations.

Sucuri also provides a similar tool. But I found KeyCDN‘s results more accurate.

An ideal TTFB:

ideal ttfb

Measure Server Hardware

Your hosting provider should have good hardware to execute PHP scripts and MySQL queries fast. It comes from the combination of a good SSD, RAM and CPU.

WPPerformanceTester is a plugin developed by Review Signal which will execute some PHP scripts and MySQL queries to benchmark your server.

Once the test results are complete, it will show your current server’s results with industry-standard (‘Your Results’ should be lower than ‘Industry Average’).

wpperformancetester graph
wpperformancetester results

Measure Scaling

What happens when your blog post went viral one day? Are you sure that your hosting could handle it?

There are some limits on the numbers of requests (users) a server could handle. Database (MySQL) is usually a bottleneck. Redis, horizontal scaling of PHP containers could help.

It’s always a good idea to measure how much users your server could handle. This is also known as a stress test or load test. Here is how can you can do it in WordPress:

A good hosting provider can handle a minimum of 1000 requests per second

Consistent Performance

Ok, so your hosting provider performs well during the testing period. But what if they’re sharing your resources with other websites?! Whenever they’ve some heavy jobs like backups, your site should not be slow.

It’s not just shared hosting, even premium managed hosting providers share your resources with others. That’s why most of them have a list of disallowed plugins.

Use services like UptimeRobot that will continuously monitor your response time. You should run this test for a minimum of 24 hours.

uptime robot dashboard

Why you shouldn’t consider Fully Loaded Time

The location of the server, CDN provider, use of external resources all impact fully loaded time. It may vary from time to time and the test location. So it’s better not to consider fully loaded time while benchmarking a hosting provider.

Conclusion

Never go with shared hosting!

Choosing a VPS can give you good results in TTFB, server hardware and consistent performance. But a single VPS won’t be able to handle load beyond a point. That’s the advantage of managed hosting providers like Kinsta. They’ll scale accordingly.

So these are the 4 ways I test or benchmark different hosting providers.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/benchmark-wordpress-hosting/feed/ 0
Improving TTFB with TLS 1.3 in WordPress https://wpspeedmatters.com/tls-1-3-in-wordpress/ https://wpspeedmatters.com/tls-1-3-in-wordpress/#comments Mon, 15 Jul 2019 16:57:13 +0000 https://wpspeedmatters.com/?p=2046 TTFB (Time to First Byte) is one of the hardest one to optimize in WordPress.

Recently I was playing around with Google Cloud infrastructure for running WordPress. While testing I noticed something. Without HTTPS I was able to achieve <200ms TTFB in most of the regions around the world. However, after enabling HTTPS, it’s only 3 or 4 regions. The TTFB increased by 100-200+ ms.

without https
Without HTTPS
with https tls 1.2
With HTTPS

So I did some research on how to improve TTFB enabling HTTPS.

What is TLS?

TLS or Transport Layer Security is a successor of Secure Socket Layer (SSL). A protocol used to provide end-to-end encryption while transmitting data through HTTP.

Will TLS or HTTPS slow down my site?

In short, Yes.

Every time you make an HTTPS request, your browser has to exchange some keys and do the handshake. It usually takes a few round trips to make this happen.

Here is the time your browser spends to connect and make an SSL connection.

tls timing pingdom
SSL Handshake and Connection Time

The new TLS 1.3

TLS 1.3 is a new version of TLS which was released in August 2018. The major difference in TLS 1.3 when compared to the previous version 1.2 is the number of round trips.

tls 1.2 handshake
TLS 1.2
tls 1.3 handshake
TLS 1.3

Now let’s see how it really affects our TTFB.

with https tls 1.2
TLS 1.2
tls 1.3 ttfb
TLS 1.3

TLS 1.3 Browser Support

TLS 1.3 is released in August 2018. So some old browsers won’t support it. It’s good to have both TLS 1.3 and 1.2 in your server.

tls 1.3 browser support
Source: Can I use

How to find a website’s TLS version?

Open your website and check the ‘Security’ tab in developer tools (Ctrl+Shift+I or Ctrl+Opt+J).

tls version check

How to enable TLS 1.3 in WordPress

If you’re using premium managed hosting providers like Cloudways or Kinsta, it’s already enabled by default.

Cloudflare

If your website is behind Cloudflare HTTP proxy, then it’s enabled by default. You can find it under the ‘Crypto’ tab.

tls 1.3 in cloudflare

Apache

TLS 1.3 is now supported in Apache2 version 2.4.36. If your Apache server version is below that, better upgrade it.

You can find your current apache version by apache2 -v command. To upgrade apache run the following commands.

sudo apt-add-repository ppa:ondrej/apache2
sudo apt-get update
sudo apt-get dist-upgrade

Nginx

You must have Nginx version 1.13.0 or greater built against OpenSSL 1.1.1 or greater, and a valid SSL certificate.

In Nginx configuration file, add TLSv1.3 to the ssl_protocols directive, like:

ssl_protocols TLSv1.2 TLSv1.3;

Full conf file

server {

  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  server_name example.com;
  root /var/www/example.com/public;

  ssl_certificate /path/to/your/certificate.crt;
  ssl_certificate_key /path/to/your/private.key;

  ssl_protocols TLSv1.2 TLSv1.3;

}

Make sure you restart Nginx by:

sudo systemctl reload nginx.service

Conclusion

It’s a small tweak, but enabling TLS v1.3 helps to improve TTFB a lot, as well as security. Make sure your CDN also supports TLS 1.3.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/tls-1-3-in-wordpress/feed/ 3
6 Levels of Caching in WordPress You Need to Know https://wpspeedmatters.com/levels-of-caching-in-wordpress/ https://wpspeedmatters.com/levels-of-caching-in-wordpress/#respond Fri, 21 Jun 2019 07:20:11 +0000 https://wpspeedmatters.com/?p=1648 If you’re curious about WordPress speed like me, you must have heard the word “caching”. But “caching” / “cache” is a very generic term. In WordPress, there are 6 levels of caching.

Cache Pyramid
6 levels of caching in WordPress

Opcode Cache

A PHP code is written in a human-readable form. But in order for a computer to understand it, it must be converted to a machine code or bytecode. By default, on every request server needs to compile this into machine code.

Opcode caching saves the converted bytecode in memory so that for subsequent requests this conversion is not needed.

PHP v5.5 and above ships with Opcode caching bundled. Contact your hosting provider to confirm it.

opcache

Object Cache

MySQL is very resource-intensive. Every time you open a page/post in WordPress, it has to execute a minimum of 27 MySQL queries. 27 is the default queries count, it may be 50 or 100 depending on your theme and number of plugins installed. Each of these queries may take a few milliseconds depending on the size of the SQL query and the data in your database.

Most of the time, these SQL query results can be cached, either in disk or memory (RAM), called object caching. Thus we’re speeding up the queries by offloading the work from MySQL and also use fewer server resources.

Redis and Memcached are two similar software that will cache these results in memory. The read and write speed of this software are far higher than databases like MySQL/MariaDB.

Full Page Cache

If you have a blog post or woocommerce product, the content doesn’t change often. So it’s ideal to generate an HTML version of that page instead of generating it from PHP for every request.

This is what full page caching does. It generates full the page in HTML stores it on the disk. Subsequent requests serve these HTML files directly.

Cache plugins like FlyingPress generate well-optimized pages from their servers and store them on your server.

HTTP Accelerators

This is the next level of full-page caching. The generated pages in ‘full page caching’ are stored on a hard disk. Reading and writing from hard disks (even SSD) are slow when compared to reading that from In-memory (RAM).

As you have seen above, Redis and Memcached are really good at in-memory caching. However, Varnish is specifically designed for caching HTTP requests and provides many other features than Redis. FastCGI with Nginx can also be configured to achieve the same in-memory caching.

CDN

CDN (content delivery network) is a network of servers spread across the world. You can store a copy of your static files (css, js, images etc) in those servers. So next time when someone visits your site, the static files will be delivered from the nearest server of your CDN.

If yours is mostly a static website, you can also cache HTML pages in CDN.

Browser Cache

While sending an HTTP response, you tell the browser whether to cache the response or not. Once it’s cached, for subsequent requests, the response will be taken from the browser cache. You can also tell the browser how long to cache the files.

It’s a good idea to cache static files like CSS, JS, images, fonts in the browser since they’re not updated often.

Which Type of Caching Should I Use?

Opcode caching is enabled by default by most of the good hosting companies. Browser caching and CDN caching is easy to implement and is advised for all kinds of websites.

If your website doesn’t have much dynamic content, then you should definitely implement full page caching. HTTP accelerators can also boost a lot of speed and handle high traffic in this case.

But if your site has a lot of dynamic contents, full-page caching and HTTP accelerators caching won’t be possible on every page. So it’s highly recommended to cache queries using Object caching.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/levels-of-caching-in-wordpress/feed/ 0
OpenLiteSpeed vs Nginx in WordPress – TTFB, Load Time, Stress Test Results https://wpspeedmatters.com/openlitespeed-vs-nginx-in-wordpress/ https://wpspeedmatters.com/openlitespeed-vs-nginx-in-wordpress/#comments Fri, 14 Jun 2019 16:45:03 +0000 https://wpspeedmatters.com/?p=1535 LiteSpeed is a new web server in the market which claims to give more performance than Apache and Nginx.

I found this image from their website, openlitespeed.org:

apache vs nginx litespeed
Image from OpenLiteSpeed Website

and one of the members of our Facebook group asked this:

ls fb question

So I decided to give it a try and test it with the popular web server, Nginx

What is a Web Server?

A Web Server is software installed on your server which is responsible for receiving HTTP requests, processing them and sending back the response. To process it, a web server may request additional programs like PHP to get the output.

OpenLiteSpeed vs Nginx

Nginx (recently acquired by F5) is a very high-performance web server, released in 2004. Initially made as a load balancer and reverse proxy, but due to its high performance, it became very popular and used by millions of sites. Nginx has an open-source “Nginx” and “Nginx Plus” for enterprise (paid).

LiteSpeed is a similar webserver to Nginx released in 2003. LiteSpeed is currently the 4th popular web server. LiteSpeed can be a drop-in replacement for Apache because it can read and load .htaccess files. Recently they released an open-source version called OpenLiteSpeed with limited features of LiteSpeed.

What about Apache? Read the guide from Kinsta – Nginx vs Apache: Web Server Showdown

LiteSpeed and Nginx use an event-driven architecture. Both are really good at serving static files, uses dramatically less memory and can handle more than four times more requests per second when compared to Apache.

Test Configuration

Here is the test configuration that I used to test both:

  • DigitalOcean server with the same resources ($5 droplet)
  • Same server location (San Fransico)
  • Astra theme with a default demo site
  • Nginx via EasyEngine
  • OpenLiteSpeed via DigitalOcean marketplace
  • Cache plugin – WP Rocket on Nginx and LiteSpeed cache on OpenLiteSpeed
  • No CDN, Redis or Varnish caching
  • No Cloudflare proxy (DNS alone)

Here is the screenshot of the sample site that I used:

sample site for test

Test Results

Time to First Byte (TTFB)

TTFB is the time taken for the browser to get a response from the server. This metric can also be called as the server response time (server response time + network latency = TTFB).

Since TTFB varies based on the network and test location, I tested it from 14 locations. Here are the results:

Nginx

nginx ttfb
Nginx – TTFB

OpenLiteSpeed

litespeed ttfb
OpenLiteSpeed – TTFB

Winner

OpenLiteSpeed has a better TTFB when compared to Nginx, starting from saving 50ms to 150ms to remote regions. In TTFB, even 50ms matters a lot. Google recommends having a TTFB of <300ms

If your server and audience are in the same region/country you might not feel a big difference, but otherwise, OpenLiteSpeed is the winner here.

Fully Loaded Time

Fully loaded time is the time taken to download and process all requests on the web page. The test was done using GTmetrix and here are the results:

Nginx

nginx gtmetrix 1
Nginx – Fully Loaded Time

OpenLiteSpeed

litespeed gtmetrix 1
OpenLiteSpeed – Fully Loaded Time

Winner

Nginx has a slight advantage of 0.1 seconds. It can be mainly due to the fewer requests made by the WP Rocket cache plugin, while OpenLiteSpeed was using its own LiteSpeed cache. Again, it’s a small difference. So it’s hard to pick a winner here.

Load Test / Stress Test

Load test (also known as a stress test) is a type of test where we send huge traffic within a short period of time. This test helps to determine how a web server responds to high traffic or when one of your blog posts goes viral and there is a sudden flood of visitors.

So I did a load test on each by sending up to 10k requests per second over a period of 1 min (starts from 0 req/sec to 10k req/sec).

Here are the results:

Nginx

nginx load test 3
Nginx – Load Test

OpenLiteSpeed

openlitespeed load test 1
OpenLiteSpeed – Load Test

Winner

While sending 10k requests per second, in Nginx almost 50% of the requests were timed out (didn’t get a response in 10 seconds). In the case of OpenLiteSpeed, it’s only less than 6%.

The average response time is also much better for OpenLiteSpeed. While Nginx had 5.7 seconds, OpenLiteSpeed is 2.8 seconds!

It clearly shows OpenLiteSpeed is the winner here.

Conclusion

OpenLiteSpeed has a better TTFB and can handle very high concurrent users when compared to Nginx. OpenLiteSpeed also uses fewer server resources when compared to the Nginx stack, which results in reduced server costs.

Not just performance, here are a few other reasons why I prefer OpenLiteSpeed over Nginx:

Hosting Providers with OpenLiteSpeed

Since OpenLiteSpeed is fairly new to the market, unfortunately, there aren’t enough hosting companies that support OpenLiteSpeed. The big giants like Kinsta, WP Engine still uses Nginx. They’ve years of experience in optimizing it, and they might not be even switching to OpenLiteSpeed soon.

But here are some hosting providers that give WordPress on OpenLiteSpeed/LiteSpeed

  • Closte.com – Built on top of enterprise LiteSpeed, Google Cloud and Google CDN. It’s little pricy when compared to other hosting providers and it’s a pay-as-you-go model. WP Speed Matters is currently hosted on Closte.com
  • A2 Hosting – Mixed reviews, I haven’t personally tested them yet
  • DigitalOcean – DO provides a one-click installer to install OpenLiteSpeed easily. If you’re ok with managing servers your own, go for it

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/openlitespeed-vs-nginx-in-wordpress/feed/ 3
9 Tips to Reduce TTFB in WordPress https://wpspeedmatters.com/reduce-ttfb-in-wordpress/ https://wpspeedmatters.com/reduce-ttfb-in-wordpress/#comments Fri, 10 May 2019 10:39:39 +0000 https://wpspeedmatters.com/?p=1148 TTFB or Time to First Byte is the hardest thing to optimize in WordPress. This guide will help you with implementing some easy steps to improve TTFB.

What is TTFB?

Time to First Byte. As the name suggests, it’s the time required to receive the first byte from the server, or inessential how fast your receive data when requesting a webpage.

TTFB vs Loading Time

Sometimes TTFB is confused with the loading time of a website. However, they’re not the same. Loading time refers to the total time of a request which includes sending, TTFB, downloading, parsing, etc.

How to Measure TTFB?

There are several tools to measure the TTFB. My favourite one is https://tools.keycdn.com/performance because it will do the test from 14 locations.

ttfb perfomance result

What is Good TTFB?

Google recommends having a TTFB of a maximum of 200ms. Even 200-400ms is ok. Anything beyond 500ms is considered slow. It will clearly affect the whole speed of the website and user experience.

How to Reduce TTFB in WordPress?

Use Cloudflare DNS

DNS has a vital role in page speed and TTFB. It is how your browser finds your server and connects to it. The faster your browser connects to the server, the faster TTFB!

Here is a comparison of the response time of Cloudflare DNS with popular services:

ProviderProvResponse Time (lower is better)
Cloudflare12 ms
GoDaddy48 ms
Route 53 (AWS)49 ms
Google Cloud59 ms

Use a Cache Plugin

For every new request to a page, WordPress has to execute PHP and MySQL queries. But 90% of the time you don’t need it. You can generate HTML files and serve them directly. It’s very fast when compared to generating it from PHP.

There are several plugins that help you to enable cache in WordPress.

FlyingPress is an all in one optimization plugin with caching (built by myself).

Use a VPS server or High Performance Managed Hosting

Unlike shared hosting, VPS servers and a few managed hosting providers don’t share resources across other sites. What this means for you is a faster website.

Here are a few that I recommend:

Use PHP v8.0 (or the latest version)

If caching or a static website isn’t a good solution (especially for e-commerce, forums) then speeding up processing is the only way. It’s not just about increasing CPU and RAM.

Even though it’s a smaller upgrade in the number, the performance is notably different!

php benchmarks 2021 wp 5.6
Source: Kinsta

Use TLS 1.3

TLS is the successor of SSL. It’s a protocol to provide end-to-end encryption (HTTPS). TLS 1.3 is the latest version. Version 1.3 reduces the number of round trips and provide a significant improvement in TTFB.

It requires only a few changes in the server, but you could reduce up to 250ms just by upgrading to TLS 1.3.

Choose Server Location Wisely

If your audience is in India and your server is in the US, that will add an extra 200-300 ms network latency.

Select your server location wisely. Choose the server that is very close to your audience location. Most of the cloud hosting providers like Cloudways, Kinsta has locations all around the world.

digital ocean locations
Cloudways (DigitalOcean) locations

Use OpenLiteSpeed or LiteSpeed Server

LiteSpeed is a web server similar to Nginx and Apache which provides much better performance, especially in terms of TTFB. OpenLiteSpeed is the open-source version of LiteSpeed enterprise.

Cache HTML Pages on CDN

An HTML page is the first piece your browser asks when a user visits your website. Due to several factors, Cloudflare by default won’t cache HTML/JSON. However, you can write custom rules to cache HTML pages in their CDN servers. This will decrease the TTFB by 10x or even more!

Use Cloudflare Argo

Argo detect real-time congestion and route web traffic across the fastest and most reliable network paths

Cloudflare

Cloudflare powers 10% of the internet! They know which is the fasted path to deliver. With Cloudflare Argo, you can speed up the TTFB by 35%.

Argo isn’t free, unlike the above services. It costs $5.00/month + $0.10 per additional gigabyte.

Conclusion

The first impression is the best impression. TTFB is more important than your total website load time. I hope the above steps will help you to decrease the TTFB.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/reduce-ttfb-in-wordpress/feed/ 8
How to Load Test a WordPress Website https://wpspeedmatters.com/how-to-load-test-a-wordpress-website/ https://wpspeedmatters.com/how-to-load-test-a-wordpress-website/#comments Mon, 22 Apr 2019 05:53:54 +0000 https://wpspeedmatters.com/?p=967 A load test or stress test is measuring how many visitors your site could handle. Technically Requests per second!

This guide is all about load testing WordPress sites, some tips on how to handle sudden spikes, and how I handle it.

Why you should Load Test?

What happens when your blog posts go viral? You’re going to get tons of traffic! This is what happened to me when one of my posts gets featured on Hacker News.

realtime users google analytics

Well, 237 real-time users are not that great, I’ve seen bloggers with 1k-2k real-time users!

Unless you properly load test a site, you don’t know whether all users are able to open your site during these spikes.

Trust me, only a few hosting providers in this world can’t handle this! (listed at the bottom).

Before Load Testing

Load testing is done by sending fake users to your website/server. Here are some points that you need to consider before running a load test.

  • Some hosting providers charge based on the number of users/visits.
  • While load testing your site may become unavailable to some users based on the load capacity of your server (that’s what we’re going to test).

How to Load Test a WordPress website?

There are several tools and services that can do a load test. In this guide, we’re going to use Loader.io.

Why Loader.io?

  • Free (freemium)
  • Supports up to 10k users in the free plan
  • Easy to use interface
  • Supports incrementing users
  • Cloud-based
  • Developed by SendGrid (a leading email service)

Create a free account and verify domain

Create an account on Loader.io and verify your domain. You’ll need to download a file and upload it to the root of your WordPress directory (verification via DNS is in their paid plan).

load test wordpress

Create a new test

Now let’s create a new test (aka load test) as follows:

loader.io

Note the “Test Type”. There are multiple options like clients per test, clients per second, and maintain client load.

Maintain client load will start sending zero users and gradually increase it second by second. In such a way we can make sure that at what point it breaks!

Analyzing Test Results

Once your test is complete, you’ll get a report like this:

loader io test result 10k

The key element we’ve to look for is the ‘Response Counts’. The counts other than success means that many requests failed.

Luckily none of them failed for me! (I don’t believe in luck, learn how I did it below).

How to handle High Traffic in WordPress?

As you can see I was able to test 10k users per second with a 100% success rate. The main trick that helped to achieve this is to cache HTML pages in Cloudflare. Here is how you can do it – Caching WordPress Pages at the Edge using Cloudflare.

Even though this trick works pretty well for me, not everyone can implement it if you have a lot of dynamic content. In such caches here are some tips:

  • Never use shared hosting. Use a VPS server like Cloudways or managed hosting providers like Kinsta. These guys really know to handle scaling and handle traffic
  • Implement Redis/Varnish caching
  • Offload the server load using a CDN. Use Cloudflare (free) or any plaid ones like BunnyCDN or KeyCDN
  • Create a static version of pages. Use a cache plugin like FlyingPress.
  • Compress images
  • Minimize HTTP requests

Conclusion

It’s very important to run a load test and make sure your WordPress site is ready to handle high traffic. Otherwise, you’re going to lose some precious users!

Running a load test is pretty easy as we covered. However, achieving high RPS (requests per second) is very hard. I’ll share many more tips across this blog.

Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

]]>
https://wpspeedmatters.com/how-to-load-test-a-wordpress-website/feed/ 1