0
votes

I'm running a backend app on App Engine (still on the free plan), and it supports client mobile apps in a Firebase Realtime Database setup. When a client makes a change to the database, I need my backend to review that change, and potentially calculate some output.

I could have my App Engine instance sit awake and listen on Firebase ports all the time, waiting for change anywhere in the database, but That would keep my instance awake 24/7 and won't support load balancing.

Before I switched to Firebase, my clients would manually wake up the backend by sending a REST request of the change they want to perform. Now, that Firebase allows the clients to make changes directly, I was hoping they won't need to issue a manual request. I could continue to produce a request from the client, but that solution won't be robust, as it would fail to inform the server if for some reason the request didn't come through, and the user switched off the client before it succeeded to send the request. Firebase has its own mechanism to retain changes, but my request would need a similar mechanism. I'm hoping there's an easier solution than that.

Is there a way to have Firebase produce a request automatically and wake up my App Engine when the db is changed?

3
Hi, does it need to be real time? Or would it be acceptable to trigger a listener every 4 hours, for example? - Renaud Tarnec
Real time. User expects the calculation result within seconds. - jazzgil
Ok, so what I had in mind (cloud.google.com/solutions/mobile/…) would need to have an instance running 24/7 (due to manual scaling) and therefore will not fit with a free plan. This is in line with Dan Cornilescu's answer below. - Renaud Tarnec

3 Answers

2
votes

look at the new (beta) firebase cloud functions. with that, you can have node.js code run, pre-process and call your appengine on database events.

https://firebase.google.com/docs/functions/

1
votes

Firebase currently does not have support for webhooks.

Have a look to https://github.com/holic/firebase-webhooks

0
votes

From Listening to real-time events from a web browser:

Posting events back to App Engine

App Engine does not currently support bidirectional streaming HTTP connections. If a client needs to update the server, it must send an explicit HTTP request.

The alternative doesn't quite help you as it would not fit in the free quota. But here it is anyways. From Configuring the App Engine backend to use manual scaling:

To use Firebase with App Engine standard environment, you must use manual scaling. This is because Firebase uses background threads to listen for changes and App Engine standard environment allows long-lived background threads only on manually scaled backend instances.