Thursday, February 1, 2024

Spikes In CPU

Related to this post I quite often see big spikes in my CPU usage on my cloud compute instance which grinds my blog to a halt.

This is the CPU usage over the last 14 days:

We can see that there's 3 occasions where usage has basically gone to 95% which is bad.

I've tried a few things to stop this from happening:

  • Rate limiting (using nginx)
  • Using renderToReadableStream instead of renderToString on the server, this was an easy win but I think it just slightly improved performance
  • Ensuring everything is properly cached with Cloudflare, I'm still not sure if I'm doing this properly

It's definitely been a learning experience so far investigating this stuff. Hopefully I can debug what the exact cause is. Maybe it's still multiple things?