4
8 Comments

$70 US bill for GCloud SQL PostgreSQL database in one week :(

I'm currently building a simple NodeJS backend connected to a PostgreSQL database (us-central1 region) hosted on Google Cloud which during the past few weeks has already cost me almost $100 USD

Unfortunately I noticed that during my hasty setup, I did not change the defaults which seem pretty hefty e.g. 100GB SSD storage which I definitely do not need since it's just a few tables

Are there any guides or basic configurations that I can utilize to save cost or should I switch to a different platform?

  1. 1

    As you noticed, if you go with the defaults when you create a Cloud SQL server, you will get a machine that is configured for medium-to-heavy database loads. It sounds like you are building a simple app that doesn't need that power, or the bill that comes with it. I would go back and create your Cloud SQL instance again, click "Show configuration options", click "Machine types and storage", and pick one of these machine types:

    Cores: 1 shared vCPU, Memory: 0.6 GB -- $9.37/month
    Start with this. It works well for development. If it's too slow in your production environment, upgrade to the machine type below.

    Cores: 1 vCPU, Memory: 3.75 GB -- $27.25/month
    If your database is small there is a good chance that it will fit in RAM, which is good for performance.

    Best of luck!

  2. 1

    Whatever platform you are going to choose, set alerts for yourself. There are many articles by devs who suffered exorbitant bills due to these types of problems

  3. 1

    I've switched from developing robust backend REST or GraphQL API's on whatever cloud (Azure, AWS, Google) which connect to a DB to using 'serverless' functions (AWS Lamda, Azure Serverless, Google Cloud Functions) that connect to whatever NoSQL DB the cloud platform has to offer.

    In my case, I migrated from:

    .NET REST API's on Azure using Docker images and connecting to Postgress on Azure

    To

    Mongo Cloud - MongoDB on the cloud & Realm serverless functions which talk directly to MongoDB's. There are free tiers you can use for development. Saved me a ton of time and money.

    In this scenario, you don't need NodeJS / Express API's. Such a waste of time if you are a solo developer or small team trying to launch a product.

    Just my opinion. Curious to hear others.

    1. 1

      How have you found the scaling, cost-wise? From everything that I've read, serverless doesn't scale as effectively when it comes to cost (though it's great for things that don't run often or don't have high traffic).

      1. 1

        In my case, the cost of scaling is not a concern because I don't have 'high' traffic yet. However, if I ever need to scale due to 'high traffic', then the cost of scaling is orders of magnitude less than the cost of hand-coding my api's, going down the rabbit hole of microservice architecture along with domain-driven design, deploying and managing docker containers, etc.

        Let's say anecdotally I got 50,000 customers with 100,000 requests/sec and that equated to $800/mo in cloud computing cost, but I got things done in 70% less time - Isn't that worth $800/mo? After all, 50,000 customers would equate to $750,000 /mo. That's not a bad trade. Invest $800, less development time, and get back $750K. (Yeah, I'm exaggerating, but you get my point)

        Alternatively, yeah you could code several microservice API's in NodeJS/Express (or other stack), use an ORM or DB library, and get your data sent to your clients in JSON/GraphQL. It just seems to be a waste unless you have compelling reasons to go with intelligent domain rich models and N-tier design.

        I'm not saying that serverless, cloud-native architecture is the solution to everything, but I am saying if you are a time and cost-conscious early startup, why all the headaches with the complicated alternatives?

        What interesting is that back in the day before N-Tier architecture (fat-server), there was client-server architecture (fat client). With serverless is more like thin-client, and thin-server.

        Here's a good article:
        https://www.mongodb.com/blog/post/serverless-architectures-the-evolution-of-cloud-computing

        I'm sure you can find similar articles for
        Azure, AWS, Google.

  4. 1

    The default machine is quite powerful, I never take that for a new project. It has 4 vCPU and 26GB of memory with 100GB of SSD.

    Scale it down to the lowest possible 1 shared vCPU with 0.6GB of memory if your site barely has any traffic. You can scale it up later if you need. Take the minimum SSD with 10GB and enable automatic storage increase. This shouldn't cost more than $10 a month.

    1. 1

      I agree with @Kansuler. I'm not sure if you're comfortable building and managing the db yourself but I've run some decent size projects with a Postgres database on a few different cloud providers on servers that cost me $5 or $10 a month.

  5. 1

    I'd figure out where the bulk of the costs are coming from and see if you can downsize that. I'm not familiar with Google Cloud but they should have a way to see a breakdown of these costs. It's a waste to pay for something you're not using.

    You say you have a few tables, how many rows do you have in them? How much storage are you using now?

    Migrating away could help but it would be a bigger hassle than figuring out what you need and just pay for that. Google Cloud is a big market player and their price is not that different from AWS or Azure, not at your scale.

Trending on Indie Hackers
After 10M+ Views, 13k+ Upvotes: The Reddit Strategy That Worked for Me! 38 comments Getting first 908 Paid Signups by Spending $353 ONLY. 19 comments 🔥Roast my one-man design agency website 18 comments Launch on Product Hunt after 5 months of work! 16 comments Started as a Goodreads alternative, now it's taking a life of its own 12 comments I Sold My AI Startup for $1,500 and I'm Really Happy About It 11 comments