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.

질문됨 2년 전500회 조회
1개 답변
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
전문가
Chris_G
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠