Creating My Own PaaS: Azure and AWS at Home (P2)

The 7 Recreations Of My PaaS

About 3 months before the creation of this post, I created a blog post reflecting on my time coding my own PaaS ( I highly recommend reading that blog post if you haven't already ). At the time I only finished about half of my PaaS - the backend, I still had to do the UI and add a few other bits and pieces. However, after completing the blog post, I wasn't all too happy with the state of the PaaS, so I decided to restart from scratch. Little did I know that this restart would not be the last.

Since then I've restarted, not once, not twice, not thrice but 7 different times. You may be wondering why, I wonder that too.. during the 7th restart, I decided that I wouldn't restart again. I knew if I kept restarting then I would take this project to the grave. Luckily the 7th version wasn't all that bad I'm quite happy with the state of my PaaS right now. So I finally decided to provide an update!

Why the 7th throw stuck?

Many hands make light work

The key difference between the 7th PaaS version and all the others is that the 7th version uses Nixpacks. For those who may not know, Nixpacks is an image builder made by Railway, it takes a project's source code and automatically builds an image for it that you can then deploy.

This "image building" part is an essential part of any PaaS because it makes or breaks the deployment process. Before I started using Nixpacks I was just throwing my own Dockerfile in a project which assumes the project is a NodeJS project, and for any other type of project, I'd have to manually make a new Dockerfile. This overcomplicated things by a lot, since I use Nixpacks now - I not only have automatic image building but my code is a lot more manageable.

Less is more, keeping things simple

Another big issue with the previous version is my tendency to overcomplicate. What I usually did was implement some sort of middleware between my app and the database that automatically caches data, and while it worked very well to make my app a lot faster, it also added a lot of unneeded complexity. In the 7th version, I tried focusing more on simplicity.

This made my code a lot less difficult to navigate and maintain, which made me enjoy working on it a lot more than I did before.

Polishing the Gem

Lastly, I feel telling myself that I won't make more versions really forced me to go back and refactor code to ensure longevity and robustness. I definitely still need to go back and refactor some more but I think it's totally manageable for now.

Cutting the Dead Weight

In the previous versions, I was using Cloudflare, not only for security and performance but also for SSL/TLS. However, I later found out that my app was extremely slow for no reason, a blank HTML page took 500ms to load - from a computer 5 feet away from the server the page was loading from. I immediately thought it was Cloudflare and tried disabling CF proxy, but it didn't help my cause, after 3 days of debugging and trying to find the cause, a friend asked me to disable Cloudflare entirely. After doing that my website was blazingly fast.

What happened was Cloudflare was routing my app's requests extremely poorly, requests for my website were coming from London. I reached out to Cloudflare and they said it was my ISP's fault, but I had friends from other continents test too and they had the same issues with it being unreasonably slow. I decided I'd just drop Cloudflare, the security benefits did not outweigh the slow speed of my site. After I dropped Cloudflare, my site's response times went from 500ms to 5ms.

New features

The new version also has a lot of new features, the biggest of which is a CD. A CD ( Continuous Deployment ) is a service that allows you to easily deploy completed code automatically. This was very needed in my case since it makes updating my PaaS a lot smoother and easier to do, which makes it easier for me to work on.

Another feature is statistics with Grafana, I can now monitor everything about my app using Grafana, which I initially only deployed to help me find the issue with load times I spoke of before, but it ended up being very insightful and I love just staring at my statistics!

Future Goals for the PaaS?

I have a few awesome plans for this PaaS, firstly - I want to add a db feature in the PaaS that allows me to easily deploy a database inside of my PaaS from a predefined image. Although I'm also content with using third-party database providers since they often offer extremely generous free tiers and also make migrating my project around a lot easier since I don't have to worry about migrating my databases, so I'm not in any rush to add this.

Another thing I want to add is a docs page, currently, nothing is documented, so it'd be a good idea to document a few things before I forget them, although if I do forget them then I can always just peak at the code, so this is also not on top of my priority list.

I think for now I can finally start migrating my projects onto my PaaS. It's been a blast working on this PaaS, I've learned so much while doing it, and I highly recommend it!