Weekly Optimization #1 - Improving Loading Times

Every Week I improve my sites a bit. This helps to make the user experience constantly better. This week the hosting situation got a lot better and loading times should be a lot better now.

Weekly Optimization #1 - Improving Loading Times

My new Post Series “Weekly Optimization” will aim to make NATON.DEV and PYKIT.ORG better every week. Starting today, the website will load faster.

Every Wednesday, I will create a new post with the optimization of the week. This is, in the first place, a great thing to make the Site better, create content and learn something. Technically, insights will be the core of the posts.

Previously, both websites were behind Cloudflare. Normally, this is a good thing, but since my server is based in Germany and Cloudflare detected somewhere else as the best location for most countries, the traffic was traveling across the globe to reach the destination server. This resulted in terrible loading times and sometimes even the site not loading. To improve this, I rethought my hosting strategy.

Previous Hosting Situation

Some months ago I decided to create a Kubernetes Cluster for tinkering around a bit with scalable Hetzner Kubernetes. For this, I used some generation tool. I don't even know the name anymore, but it wasn't kOps. The tool was good, and I started using the cluster a bit too much, and it quickly generated me too much load balancers because for every ingress service it generated a new load balancer, which I don't quite like. Probably easy to configure otherwise, but it fell a little behind and I didn't mind much. So it ended up costing a lot, but wasn't well-maintained by me.

Another problem, except the costs, were the loading times. Sometimes I couldn't use the sites, and it was a pain to navigate around, but sometimes it worked well. At first, I suspected the Kubernetes cluster too, but on the migration my main thought was the latency from Cloudflare, which my only explanation is that Cloudflare uses a very far server.

As you see, the first ping even timed out. This is not very good. I could live with it when I would know the connection between Cloudflare and the origin is good, but I also don't think that because the Datacenter probably also has a >100ms connection to this specific IP. I suspect Argo Smart Routing would fix that, but currently our sites are not that popular that it would be reasonable.

What have I changed?

I simply moved it to my home lab and removed Cloudflare. This has some improvements:

  • very cost-efficient
  • more compute and memory resources
  • only the latency of my good internet connection matters
  • regular backups of my VM without additional costs

The downsides are not very problematic. Theoretically, someone could DDoS my Internet connection, but until this happens I will say it is not very likely. If that happens, my second connection will jump in and no important applications will be affected except the two sites.

I will keep an eye on it and improve the situation every week.