Slow Page (120++ seconds ) Load on Laravel on Lightsail Instance.

0

I installed my laravel web application on two instance. One is a 1vpu 512mb and another a 2gb with 1vpu. I notice that the app runs really fast for the first hour, taking at max only 400ms to load any page. But then all the sudden it just slow down and take 120s or more to load a single page. I check the metrics, and its been below the burstable zone (green ) all the time, with my burstable capacity still high 60%. I check the apache2 logs and nothing notable comes up. I did a check on usage and its vpu is barely used, memory was under 400mb. I check the performance and it seem it take 120 seconds of booting for each page before the page truly start loading.

To test it further, I try this again on a different instance - this time a 2gb/1vpu. Again it loaded quickly the first few load - then it slowed down and similarly takes 120 seconds to boot each page. I check the apache log, "top" and metric and similar to the first instance, there was nothing notably wrong with it.

The funny thing is, now the lower spec first instance is running quickly and only take 300-400ms to load a page, while my second instance is still running slow.

asked 2 years ago487 views
1 Answer
1

Hello,

It's really hard to say why this may happen, but I think the most common would be due to a "noisy neighbor". Since these instances are on shared resources, you're likely to run into sporadic slowness on the lower instance types. Laravel itself does not use a lot of memory & CPU (depending on how many additional 3rd party packages you're using), but any sort of external connections to databases and what not will only add to the additional latency of loading pages.

For running Laravel on Lightsail, I would also recommend switching to Nginx/PHP-FPM over Apache as you will see some additional performance with the split processes instead of the requests being cobbled together on combined Apache processes.

I also recommend using no less than 1GB of Memory because with anything lower you are likely to have a lot of memory issues. You could also enable additional storage and add swap as memory, but it will only be a marginal help.

Here's a helpful guide for adding swap to a linux instance: https://aws.amazon.com/premiumsupport/knowledge-center/ec2-memory-swap-file/. (It says for EC2, but it's relevant for Lightsail as well)

profile pictureAWS
EXPERT
Chris_G
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions