Home > Software design >  Why is Wordpress so slow on my EC2 Server
Why is Wordpress so slow on my EC2 Server

Time:08-17

I have a AWS EC2 nano server with 0.5 GB memory and ARM 1 GB CPU with 2 cores. It only has UBUNTU 22.04, NGINX 1.20 with LetsEncrypt and MariaDB installed.

I conducted serveral tests and, in order to process the following situations, I installed each of the following - IN TURN:

  • first on clean: Node.js 16.16 LTS (running from PM2 on JUST ONE CORE)
  • then also on clean: PHP 8.1 (PHP-FPM)
  • then over PHP 8.1 (PHP-FPM): a clean Wordpress 6.0.1 without any plugins only with Twenty Twenty-Two theme

For NODEJS and simple PHP I put up a mockup simple page with a DB query, while for WORDPRESS I just tested the homepage. For all of them, the NGINX cache was off.

I have done several tests with loader.io with the following results:

  1. STATIC FILE: ~ 6.000 requests/second
  2. NODEJS: ~ 3.000 requests/second
  3. PHP (SIMPLE): 1.500 requests/second
  4. PHP WITH WORDPRESS: ~ 15 requests/second

Note: it is possible for PHP to do more optimizations like OPCache etc.

So, is it something with my config or WP is so slow indeed?

From what I have seen online, they are suggesting to use NGINX as a cache in order to avoid the load, or even CloudFlare. It seems to work fine if you have just a blog, but what if the websites require dynamic content all the time, with user interaction, like Woocommerce etc.?

Is there other option to make WP quicker other then cache the pages with NGINX?

Thank you!

CodePudding user response:

Can you offload the SSL to your Application Load Balancer? That is, if you are willing to pay for it.

Also, since you are using a nano server, may I suggest utilizing the AWS Free Tier and user t2.micro EC2 coupled with a RDS. That should smoothen things up.

Also, have you tried removing your theme and/or reverting to the default theme and then observing?

You could also consider tuning some of your kernel parameters like:

vm.swappiness, fs.file-max, net.core.somaxconn, net.ipv4.ip_local_port_range, net.ipv4.tcp_tw_reuse, net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait, net.ipv4.tcp_fin_timeout

You can learn more about kernel tuning here or you could just search the web.

CodePudding user response:

I have a AWS

In Russian, we have a proverb "Слышу звон, да не знаю, где он". This literally translates as "I hear the bells, but I don't know where the sound is coming from". This well applies to folks who are opting to use AWS infrastructure just for no apparent reason other than "someone else uses it, so I should too".

Without going into details:

  • unless you just want to use free credits and are fine with slow performance, don't use AWS
  • unless you plan to use load balancing, auto-scaling, etc., don't use AWS

The default performance of "disks" in AWS is not on par with any offering of far more simple hostings like Linode, DigitalOcean, etc. Those will give you proper SSD performance out of the box, without any tuning. Should you tune up "disk performance" in AWS to match with e.g. Linode's, this will cost you!

For most medium or even large websites, a VPS from the mentioned providers or a dedicated one is a far better choice, both performance, and budget-wise.

As a performance enthusiast, I can see a notion of developers using AWS for its scaling just because they miserably fail to set up full page caching for their app. This is just throwing hardware at a problem, instead of solving it. Only a truly large app warrants the need for auto-scaling groups and other bells and whistles that most people never need.

  • Related