The cloud computing industry loves to give away free samples and Google Cloud is no different from Amazon Web Services (AWS) or Microsoft in this respect. The companies know that if you give the customers a free taste, they’ll come back when it’s time for a meal.
Google Cloud offers two types of free. New customers get US$300 to spend on any of the machines or services spread out among the 24 'cloud regions', 73 'zones', and 144 'network edge locations'. The money works pretty much everywhere in Google Cloud Platform (GCP) from raw compute power to any of several dozen different products like databases or map services.
But even when that free money runs out, the free gifts continue. There are 24 different products that offer continuous free samples that are billed as 'always free'/ Even if you’ve been a customer for years, you can still experiment.
Of course Google Cloud adds the caveat that the word 'always' in this generous promise is 'subject to change'. But until that day comes, the BigQuery database will answer one terabyte of queries each month and AutoML Translation will turn 500,000 characters from one language to another.
Some developers use the free tier for what it’s intended to be: an opportunity to explore without begging their boss and their boss’s boss for a budget. Others work on a side hustle or a website for the neighbourhood kids. When the load is small, it’s easy to innovate without dealing with a monthly bill.
Some developers take this to the extreme. They try to stay in the free tier as long as possible. Perhaps it’s because they want to brag about their insanely low burn rate. Maybe it’s just a form of modern machismo. Maybe they’re low on cash.
In any case, working this free angle as long as possible generally leads to lean and efficient web applications that do as much as possible with as little as possible. When the day comes that they leave the free tier, the monthly bills will stay small as the project scales, something that warms the heart of every CFO.
Here are a few of the secrets for squeezing every last drop of goodness from Google’s free offering. Maybe you’re cheap. Maybe you’re just waiting to tell your boss until the awesomeness is completely realised. Maybe you’re just having fun and this is a goof. Whatever the case, there are many ways to save.
Store only what’s necessary
The free databases like Firestoreand Cloud Storage are completely flexible tools that squirrel away key-value documents and objects respectively. Google Cloud’s always-free tier lets you store your first 1GB and 10GB in each product respectively.
But the more details your app keeps, the faster the free gigabytes will run out. So quit saving information unless you absolutely need it. This means no obsessive collection of data just in case you need it for debugging later. No extra timestamps, no large cache full of data you’re keeping just to be ready.
Compression is your friend
There are dozens of good pieces of code for adding a layer of compression to your clients. Instead of storing fat blocks of JSON, the client code can run the data through an algorithm like LZW or Gzipbefore sending it over the wire to your server instances, which store it without unpacking it.
That means faster responses, fewer bandwidth issues, and less impact on your free monthly data storage quota. Be a bit careful because some very small data packets can get bigger when the overhead from compression is included.
Google Cloud is more generous with their intermittent compute services that are billed per request. Cloud Run will boot up and run a stateless container that answers two million requests each month for free.
Cloud Functions will fire up your function in response to another two million requests. That’s more than 100,000 different operations each day on average. So quit waiting and start writing your code to the serverless model.
Note: Some architects will cringe at the idea of using two completely different services. It may save money but it will double the complexity of the application and that means it will be harder to maintain. That is a real danger, but often you can more or less duplicate the function-as-a-service structure of Cloud Functions inside your own container, making it possible to consolidate your code later if you plan for it.
Use the App Engine
Google Cloud’s App Engine remains one of the best ways to spin up a web application without fussing over all of the details of how to deploy or scale it. Almost everything is automated so it will deploy new instances if the load grows. The App Engine comes with 28 'instance hours' for each day—meaning that your basic app will run free for 24 hours per day and can even scale up for four hours if there’s a burst of demand.
Consolidate service calls
There is some freedom to add extras if you’re careful. The limits on serverless invocations are on the number of individual requests not on the complexity. You can pack more action and more results into each exchange by bundling all of the data operations into one bigger packet.
So you can offer silly gimmicks like stock quotes, but only if you slip the extra few bytes into the absolutely essential packets. Just keep in mind that Google counts the memory used and the compute time. Your functions can’t exceed 400,000 GB-seconds memory and 200,000 GHz-seconds of compute time.
Use local storage
The modern web API offers a number of good places to store information. There’s the perfectly good, old-fashioned cookie that’s limited to four kilobytes. The Web Storage API is a document-based key-value system that will cache at least five megabytes of data and some browsers will keep 10 megabytes.
The IndexedDB offers a richer set of features like database cursors and indices that will speed plowing through the data which is often stored without limits.
The more data you store locally on your user’s machine, the less you need to use your precious server-side storage. This can also mean faster responses and much less bandwidth devoted to carrying endless copies of the data back to your server. There will be problems, though, when users switch devices because the data probably won’t be in sync. Just make sure the important details are consistent.
Find the hidden bargains
Google Cloud maintains a helpful page that summarises all of the “always free” products, but if you poke around you’ll find plenty of free services that don’t even make the list. Google Maps, for instance, offers '$200 free monthly usage'. Google Docs and a few of the other APIs are always free.
Use G Suite
Many of the G Suite products including Docs, Sheets, and Drive are billed separately and the users either get them free with their Gmail account or their business pays for them as a suite. Instead of creating an app with built-in reporting, just write the data to a spreadsheet and share that.
The spreadsheets are powerful enough to include graphs and plots like any dashboard. If you build a web app, you’ll need to burn your compute and data quotas to handle the interactive requests. But if you just create a Google Doc for your report, you’re dumping most of the work on Google’s machine.
Strip away gimmicks
Some features of modern web applications are pretty superfluous. Does your bank application need stock quotes? Do you need to include local time or temperature? Do you need to embed the latest tweets or Instagram photos? No. Get rid of all of these extras because each one means another call to your server machines and that eats away at your free limits. The product design team may dream big, but you can tell them, 'No!'
Be careful with new options
Some of the cooler tools for building artificial intelligence services for your stack offer good limits for experimenting. The AutoML Video service will let you train your machine learning model on video feeds for 40 hours each month, before charges kick in.
The service for tabular data will grind your rows and rows of information on a node free for six hours. This gives you enough rope to experiment or build basic models, but watch out. It would be dangerous to automate the process so every user could trigger a big machine learning job.
Keep costs in perspective
It’s easy to take this game to the extreme and turn your application’s architecture into a Rube Goldberg device just to save a bit more cash. It’s important to remember that the jump from free tier to paying customer is often a pretty tiny step in Google Cloud.
While there are many free services on the Internet that jump from free to thousands of dollars with one click, Google’s services generally aren’t priced like that.
After churning through two million free invocations of Cloud Functions, the next one is a whopping $0.0000004. That’s only 40 cents per million. If you dig around your sock drawer, you should be able to cover a few extra million with little trouble.
The price schedule is generous enough that you’re not going to have a heart attack when you step out of the free zone. If your application needs a few extra million this or that, you’ll probably be able to cover it. The important lesson is that keeping the computational load low will translate to smaller bills and faster responses.