I am using a WordPress site with Woocommerce in a managed hosting service. I have taken 8GB ram's new AWS t3.large ec2 instance and installed PHP and MariaDB 10.4. After migrating my website is running but I noticed that my CPU usage went up to 90%. And it's not decreasing.
Here is the CPU usage screenshot.
Imgur
Here is my nginx config
server {
server_name beta.website.com www.beta.website.com;
root /var/www/html/website;
index index.html index.htm index.php;
#client_max_body_size 100M;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location ~ ^/wp-json/ {
rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}
location = /favicon.ico{
log_not_found off;
access_log off;
}
listen 443 ssl;
ssl_certificate /home/ubuntu/ssl/beta_website/beta.website.pem;
ssl_certificate_key /home/ubuntu/ssl/beta_website/beta.website.key;
}
server {
if ($host = beta.website.com) {
return 301 https://$host$request_uri;
}
listen 80;
listen [::]:80;
server_name beta.website.com www.beta.website.com;
return 404;
}
Information
My MySQL file size is 146MB and the backup file size is 7.5GB. My php.ini config's memory was set to 512MB.
When I saw the CPU usages I had disabled the server block in Nginx and then the server usage went to 45% and when I remove the project directory from /var/www/html
the current CPU usages is less than 1%.
Where am I making mistake?