cskth.kt
Nov 14 2023
3 MIN READ

A fix for my blog site that keeps getting unresponsive

import { Image } from 'astro

'; import dckPsRunning from './images/docker_ps_is_running.jpg' import fail2BanSafe from './images/fail2ban_safe.jpg' import digitalOceanGraph from './images/digitalocean_sample_graph.jpg' import IconRocket from '@components/IconRocket.astro'

When I first deployed this site, It keeps getting unresponsive and always hangs. I also noticed it was taking too long for pages to load.

Could it be something with the docker containers?

Nonetheless, I still try to restart them because the phrase "have you tried turning it off and on again?" worked wonders for me before (it still does tbh 🤷‍♂️). After restarting, this site becomes responsive again.

But only for a few while until it becomes dead again.

I investigate further by checking the logs of the container:

Terminal window
cd docker-ghost
dck logs db
# mindlessly scroll through logs
dck logs ghost
# mindlessly scroll through logs

Still. I didn't see anything wrong.

Wait, maybe some entity is messing up with the server.

I haven't shared this site so this is very unlikely but maybe somethings up.

So I installed fail2ban and enabled nginx-limit-req to prevent DDOS attacks.

I waited for a few days, inspected each, but yeah, no one is trying to attack my server.

Then I saw dead and empty spaces everytime the server hangs.

One obvious anomaly I noticed in the graph is the memory peaks and then it does out flat. 1GB of memory doesn't seem enough for a simple publishing site.

Issue found: Lacking memory

I had 2 options:

  • First is to get a droplet with 2GB memory. This would double my server cost.
  • 2nd option, which is a little cheaper, is to avail managed service hosting in GhostPRO.

💡Lights in my brain went on and remembered about swapfiles💡 And digital ocean has an easy-to-follow guide in adding swap space.

Conclusion

I learned about swapfiles, swappiness and vfs_cache_pressure. I learned that I'm a paranoid in thinking the server is being attacked. I learned that I'm only saving around 3-6 USD (that's 170 - 340 PHP).

But it's all worth it experiencing and learning them. Plus, I appreciated guides available online.

Great. The blog site is much more responsive now. On to the next headache.