DEV Community

Alex Saveau
Alex Saveau

Posted on • Originally published at alexsaveau.dev on

Save money with this one Firestore free quota trick for CRON jobs

I’m sorry, but I just couldn’t resist that clickbaity title. 😛 Jokes aside, let’s say you have a monthly CRON job that empties out your users’ trash and does some other Firestore related cleanup. This is a great use of Firebase Cloud Functions, but it comes at a cost: you’re creating/updating/deleting documents all in one go.

Remember, Firestore free quota resets daily. So if you’re too small to max out your free quota everyday, but too big to stay on the Spark plan, you should consider running daily jobs instead.

As long as your Cloud Functions only query the data they’re going to process, then it’ll be far cheaper to run a job every day and take full advantage of that free quota. As an added bonus, you’ll be able to better predict your monthly bill because you’ll be spreading out Firestore usage over each day.

Chris Pratt Happy

Running daily jobs

Running a daily CRON job is ridiculously easy to do: simply create aCloud Scheduler job set to run at 3am each morning(0 3 * * *) that publishes an empty data payload ({}) to a topic of your choice (daily-tick). It’ll look something like this:

GCP Scheduler Daily Tick

This tick is completely free!

In your functions’ index file, subscribe to the daily-tick pubsub event and you’re good to go.


Hopefully this will help you save a few bucks. Happy coding!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️