Over the past two years, my personal website (i.e. this site) was hosted on a self-managed cloud server running a traditional LAMP stack (Linux, Apache, MySQL, PHP) with neither elasticity nor redundancy, functioning solely as a stub for redirecting all requests to my GitHub profile. Despite this functionality being as trivial as it could possibly get, the underlying infrastructure was fragile, rigid, costly and difficult to properly manage due to the grossly suboptimal architecture.
Despite the glaring shortcomings of the above architecture, the website was basically functioning as expected so there was little incentive to improve it - after all, “if it ain’t broke, don’t fix it” - until I finally decided to re-design the entire infrastructure this week following inspiration from the excellent AWS Technical Essentials course, this time adopting a fully serverless event-driven architecture.
The current architecture is resilient, secure, elastically scalable, cost-effective and requires no maintenance of infrastructure whatsoever - a complete overhaul of the previous one. So what were some of the motivations and considerations surrounding the adoption of the previous and current architectures? Perhaps a detailed review and analysis of the historical evolution of my personal website is in order.
I was introduced to programming in 2015 through an extra-curricular activity (ECA) offered at my high school by BSD Academy (now BSD Education) on frontend web development with HTML5+CSS3+JS, for which I also picked up PHP as my first server-side programming language shortly thereafter. At the time, I only had a very basic understanding of fundamental programming concepts and had virtually no concept of IT infrastructure - to me, a server was just some machine hosted in a remote location over the Internet as far as I was concerned.
When I decided to
show off demonstrate my newfound programming skills by developing my very own website back in 2015, web hosting through the likes of GoDaddy was all the rage and the go-to option for individual users and small businesses, due to the ease of getting a website up and running without having to manage servers by oneself. Furthermore, the main offering by GoDaddy back then was a LAMP stack where the developer was only responsible for uploading HTML5+CSS3+JS code and static web assets, possibly along with PHP scripts for generating dynamic content and optionally interacting with a MySQL database managed by GoDaddy, all via a user-friendly web interface such as cPanel.
While this was the most sensible option at the time given my ability and interests back then, there are a few key disadvantages to this model:
Nevertheless, my website would be hosted on GoDaddy for the years to come, until a course offered at my university opened me to the world of cloud computing and I decided to migrate my website to the cloud.
My professional interest shifted from software development to primarily operations and maintenance of IT infrastructure when I was first introduced to Linux mid-2020 through an internship at M-Labs for which I swiftly developed a strong passion towards and earned my first professional LFCS certification shortly thereafter in July 2020, now set to expire in July 2023. This enabled me to properly understand the underlying technology stack and infrastructure powering my website on GoDaddy for the first time, though my website still remained on GoDaddy with lack of a better hosting alternative due to a missing piece of the puzzle - cloud computing.
After my internship ended in late 2020, I returned to HKUST for the final semester of my Computer Science degree where I took a course on cloud computing offered by Prof. Wei WANG which opened me to a whole new world of possibilities - in particular, the concept of spinning up an EC2 instance on AWS and getting a full-blown Linux system up and running in minutes was what really intrigued me at the time. What could possibly be better than getting a Linux system up and running in minutes, then getting my hands dirty by installing, configuring and setting up everything myself?
With the operational flexibility offered by Amazon EC2 (later migrated to Alibaba Cloud ECS in early 2022 due to non-technical reasons), I was no longer limited to the software stack offered by GoDaddy - instead, I could develop my website using the framework and programming language of my choice, install and manage the necessary dependencies myself, and manage OS and software updates at my own pace as well as SSL certificates using Let’s Encrypt and Certbot at no additional cost. So I stumbled upon Spring Framework written in Java and decided to give that a try.
It was fun and exciting developing my own website using the framework and programming language of my choice and deploying it to a cloud server fully managed and maintained by myself, while the novelty lasted. Once the novelty wore off, it became a pain, a maintenance nightmare:
Before long, I decided to ditch my website written in Spring entirely, and replaced it with an Apache web server acting solely as a stub for redirecting all HTTP and HTTPS request to my GitHub profile. Stuff that I might as well have achieved using GoDaddy, but with increased operational and monetary overhead. So at best, I was back to square 1:
Nevertheless, I stuck with this grossly suboptimal architecture for way longer than I should have due to inertia, despite having learned about the various potential benefits of managed cloud services such as elastic scalability, built-in fault tolerance and automatic security patching by going through a series of cloud-related courses and certifications since early 2022.
That was until I revisited the concept of serverless functions near the end of the excellent AWS Technical Essentials course just last week. All of a sudden, everything clicked into place - for a personal website with a low average visit rate and possible unexpected spikes in traffic that only needs to respond to stateless, short-lived web requests and doesn’t warrant ongoing maintenance of infrastructure, wouldn’t an event-driven serverless architecture using functions be a perfect fit for this use case?
So now I have an architecture that is excellent from the development, operational and financial perspective, which also happens to be extensible and future-proof:
Also, by utilizing Python-Markdown to convert Markdown templates to HTML on the fly, I can place complete focus on content when authoring long, technical blog posts like this one by writing them in Markdown and uploading them directly to Alibaba Cloud OSS when ready, instead of wasting time wrestling with HTML tags, CSS styling and page layout.
Another major advantage of utilizing Alibaba Cloud Function Compute (with OSS) as the backend and placing them behind an API Gateway is extensibility - it is simple to implement and expose new functionality for my website whenever desired by writing a new function and attaching it to the gateway via a new API, or even attaching a completely different set of cloud services to the gateway as a new API if required.
So this was an architectural overview of my personal website and how it was designed to leverage the advantages of modern managed cloud services, but we haven’t really touched on the development perspective in this article.
I hope you liked this article and stay tuned for my next article focusing on the development aspect of my personal website re-design which should be out in a day or two :-)