hitstartup

RSSEmailMastodonNewsletterTwitterGitHubDribbbleLinkedInFacebookInstagramYouTubePinterestReddit icon

Saving Cloud Costs

Posted at — Oct 27, 2021 by Abishek Muthian

Cloud infrastructure costs form the significant part of the operational costs of our Internet product and if you're a solopreneur then it likely takes the largest chunk.

Here are some tips and tricks to save cloud costs which I've learnt over the years.

Budget

One of the easiest way a fledgling entrepreneur could blow up the cloud costs without even realizing it is by not setting the budget limit on the dashboard of their cloud infrastructure provider .

We can set a reasonable budget based on our estimated usage of resources and we'd be intimated when the billing costs are over that threshold.

We can also set a withdraw limit on our credit/debit card through our bank website as a secondary layer of prevention from unexpected cost overruns like for when the cloud providers charges us for $46 Billion .

Free Resources

Major cloud providers have two kinds of free resources, One which are available during the trial period when we first sign-up, startup credits etc. like low-tier instances and the other which are always-free for certain number requests/month e.g. cloud functions, managed services etc.

Though the always-free generally do not include instances, Oracle Cloud Infrastructure(OCI) begs to differ by offering 2 x86 compute units and 4 Arm based compute unites with up to 24 GB memory !

But OCI is rife with quirks and getting access to those sweet always-free instances could be tricky, But I've got you covered; Checkout the quirks and tricks for getting access to OCI instances on my personal blog .

Such always-free resources can be used effectively to bring down the cloud costs when validating MVPs or while scaling up.

Diversification

Diversifying the usage of resources across different cloud providers can not only save costs but could also prevent downtime for our products if a cloud provider is down.

e.g.

Backups are usually charged exorbitantly by the cloud providers since backups are quintessential for safeguarding our data. Storing our backups on different cloud provider can help us reduce backup costs to a great extent.mean

Egress bandwidth for object storage is another such area where cloud providers have typically charged exorbitant fees , Newer entrant to object storage services like Cloudflare R2 has promised to do away with egress fees completely.

Storage

There are several ways cloud storage costs could go out of control, Here I detail one such often ignored mechanism which increases storage costs.

When we use managed services for deployment then the cloud provider would store previous releases for aiding roll-back which depending upon our release cycles and expiry of previous releases could put a deep hole in the pocket due the increasing deployment data size.

Limiting the number of previous releases to kept can resolve this.

Caching

Caching files, API requests can result in huge savings on network costs. Serving cached files could prevent elapsing free-tier bandwidth limits.

There are different caching service providers, The most commonly used being Cloudflare. I've seen people claiming to save 7TB of bandwidth every month with Cloudflare's free-tier caching .

Caching depends upon the request headers set by the server, Hosting services like Firebase do not cache by default and so requisite headers need to be set when using with a caching service provider. Besides, Caching .html on Cloudflare requires using wildcard on Page rules.

I set the browser cache TTL to the lowest level on Cloudflare and manually purge the cache of home page and last modified page of my website to ensure that readers don't get stale data from my website.

Domain

The first thing we do when there's a light bulb moment for a potential startup idea is to validate whether the problem has enough need-gap right? Na, Buy a domain name.

When we hoard domain names regularly for every single idea, Then the renewal-costs for the domains becomes a significant expense every year.

To address this, I've stopped buying non top-level domains for my projects like .ai, .io etc. as they are expensive to buy, even more expensive to renew and offers nothing but vanity value.

I'm also moving my domains to Cloudflare registrar as they offer domains for no additional cost over ICANN fees. But I'm hesitant as this goes against my diversification agenda and I'll become more dependent upon Cloudflare.

While Cloudflare offers the cheapest domain pricing for renewal, It's not always the case during initial purchase, Especially for the niche TLDS due to the frequent discounts offered by traditional domain name resellers like namecheap .

So my current strategy for niche TLDs (e.g. .sh) is to buy it on namecheap and then move it to Cloudflare during renewal.

Architecture

Designing the application architecture with reducing the cloud infrastructure costs as one of the goals can help us manage the cloud costs efficiently.

Every aspect of the application architecture from database to the choice of programming language can affect the scalability and thereby the cloud costs.

I've found that choosing languages which offer native concurrency like Go has directly reduced the instances needed for horizontal scaling as single instance could handle more number of users when compared to Node.js or Python.

Stack

I've been asked about my go-to stack for my projects, Since the focus of this content is about saving cloud costs I'll share my decision making process of choosing a cloud stack.

Performance is not a concern

For projects with occasional visitors where performance is not a concern, Where slow start times are acceptable since SEO scores are immaterial for the project goals.

Hosting: Heroku free-tier

Caching: Cloudflare free-tier

Languages: Go, HTML, JS

Database: Heroku Postgres

Backup: Heroku PGBackups

Note:

  1. Heroku has ephemeral file system so there cannot be locally generated files and uses port-forwarding to nodes for exposing it to the Internet, This requires specific changes in the project to accept environmental variables and to store data elsewhere.

  2. Heroku free-tier offers custom domains but doesn't offer SSL for it, So Cloudflare is required to enable SSL by using Heroku DNS via CNAME flattening .

Static Web Pages

For static blogs and where reasonable performance is a requirement.

Hosting: Firebase (Pay as you go, Google Cloud billing)

Caching: Cloudflare free-tier

Languages: HTML, PHP, JS

Note:

Firebase requires changes to headers for enabling Caching, I've detailed it earlier. The release cycle files needs to be limited to reduce the storage costs.

Greater ownership, Greater promise

For projects which requires full-control over the hosting environment. I use this for projects which are under validation with potential to make regular revenue.

Hosting: Hetzner Cloud

Caching: Cloudflare free-tier

Languages: Go, HTML, JS

Database: PostgreSQL

Backup: Restic/Backblaze

Note: Hetzner Cloud offers shared instance at reasonable price, Full disk encryption needs to be setup up manually after creating an instance.

Greater ownership, Lesser promise

For project which requires full-control over the hosting environment. I use this for projects which are showing lesser promise to make regular revenue after validation.

Hosting: Oracle Cloud Infrastructure - free-tier

Caching: Cloudflare free-tier

Languages: Go, HTML, JS

Database: PostgreSQL

Backup: Restic/Backblaze

Note: OCI free-tier has several quirks, I've detailed it earlier under Free Resources.

Greater ownership, High Reliability

For project which requires full-control over the hosting environment. I use this for projects which are the source for regular revenue and requires very high reliability.

Hosting: AWS

Caching: Cloudflare (Paid).

Languages: Go, HTML, JS

Database: PostgreSQL

Backup: Restic/Backblaze

Note: AWS costs could blow-up if not monitored carefully, Please setup budget and scale gradually.

Change Log

09-Nov-2022: Updated Domain 20-Jan-2022: Added Domain, Stack.

Newsletter

I strive to write low frequency, High quality, Actionable content on Entrepreneurship opinionated towards indies and solopreneurs. If you would like to receive them in your email inbox then please consider subscribing to my Newsletter.