Friday December 3rd 2021
I've started writing the project post about building and launching Paper Website - it's quite tough to write one after so much time. Hopefully I'll release it next week.
Another Paper Website thing I've done is dramatically cut costs for running it. In general, I try and keep all projects super cheap to run each month (about $10 max!), but with Paper Website I paid about $150 in November for server costs.
Basically, I'd coded it in a way so that every endpoint on the server was running on a different server instance. E.g. "Add Page" was on server 1, and "Save Styles" was on server 2, and so on.
I use Firebase for my backend, which is serverless by default. So this design is encouraged. Firebase will just spin up a new server whenever the API function is called. This makes things very resilient and easy - but all serverless backends are plagued by something called a cold start.
A cold start is the time it takes for Firebase (or any serverless backend) to spin up a machine to handle the request. This can be extremely slow (I'm talking 20 seconds plus for infrequently used functions). To combat this, you can pay a small fee each month to keep a serverless function running and reduce cold start times.
For speed, I did this for every backend function on Paper Website - there is about 30-40 functions, so the bill was expensive.
I've now reduced costs from $150 down to $12 per month by just grouping similar functions together on an instance. E.g. all my website editing functions are together, and all my payment processing functions are together. Now, I'm only paying for about 5 serverless functions to run continuously and remove cold start times.
Cutting costs like this is extremely satisfying, not only does it increase my top line annual profit by $1.8k, but it means that Paper Website can just exist for longer. By letting these projects just run, it opens up way more possibilities - if I was paying $150 every month for a project, maybe I'd shut it down one day because the costs were too much. What if the next the project was about to blow up? (in a good way).
Keeping costs low is a massive advantage.