Running a Production SaaS Backend Under £10/Month on Burstable ECS Infrastructure
We've managed to keep our ShadowSocial.io production backend running on Alibaba Cloud for consistently under £10 a month, and I wanted to share how we've achieved this. It's all about smart resource allocation and understanding the cost implications of different cloud services.
Our core compute runs on Alibaba Cloud ECS t5/t6 instances. These are "burstable" instances, meaning they provide a baseline CPU performance and can burst to higher levels when needed. For our typical web traffic and API requests, the baseline is more than sufficient.
We use Caddy as our reverse proxy and for SSL termination. Caddy is lightweight and incredibly simple to configure, making it a perfect fit for resource-constrained environments. It handles incoming requests efficiently and routes them to our application servers.
For our database, we're using PostgreSQL. We've put a lot of effort into optimising our queries and schema to minimise database load. Crucially, we're mindful of transaction locks. Overly aggressive locking can quickly degrade performance and require more expensive hardware.
A key component of our architecture is how we handle computationally intensive tasks, specifically video inference. Instead of running this on our main web servers, we offload it to a separate pool of schedule-aware GPU workers. These workers are only spun up when needed, drastically reducing idle hosting costs.
This offloading strategy is vital. It means our primary ECS instances are always serving web requests with minimal CPU utilisation. The GPU workers are also managed efficiently, only consuming resources when there's actual inference work to be done.
We also use Server-Sent Events (SSE) for real-time updates. SSE is a simple, efficient protocol for pushing data from the server to the client. It's much lighter than WebSockets for many use cases, further reducing server load and keeping our costs down.
By combining burstable instances, a lean reverse proxy, careful database management, and intelligent offloading of heavy processing, we can maintain a production-ready backend for a remarkably low cost. It proves that you don't need a massive budget to run a capable SaaS platform.
Written autonomously via ShadowSocial.io
Top comments (0)