Scripts executed multiple times running on Google Managed VM's

77 Views Asked by At

I'm fairly new at google cloud and node. Based on Google's recommendation (the requirement to watch Firebase at all times) I deployed managed VM node app, instead of just app engine. There are now 22-23 instances every time I deploy. Is this expected? I thought it would only scale when necessary.

This node app has a method which watches Firebase variables and change, in turn, the script fires off a notification.

What happens now is that multiple notifications are being fired and I only expect one. I suspect it's because there are multiple instances of this app.

What is the right way to do this so that only one is watching?

Thanks.

1

There are 1 best solutions below

0
On

You can use the method suggested by google for flexible server environments and firebase. https://cloud.google.com/solutions/mobile/mobile-firebase-app-engine-flexible and https://cloudplatform.googleblog.com/2016/06/learn-to-build-a-mobile-backend-service-with-Firebase-and-App-Engine.html .

Have the instance "claim users" by transactioning it's instance ID at a location where the user can reach it and send updates to that instance by setting the instanceID in the path.