I hosted a hobby site on an aws lightsail instance but it went down almost every day. It took me long to find the issue. Here's how I solved it.
I've setup a lightsail instance with Ubuntu. I figured out that the lightsail instances did not have "swap space" by default. Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space.
If your instance does not have swap space allocated, you can run the following command to allocate 2GB of swap space:
sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile && sudo sed -i '$ a\/swapfile swap swap defaults 0 0' /etc/fstab
Since then the site never went down again. Hooray!
Thanks to this author who figured it out.