I have an app written in Golang, hosted on Google App Engine and uses Firestore as a backend.
Google App Engine scales horizontally.
I use the Firebase backend to send websocket messages. So it doesn't matter which App Engine Instance the user is connected to.
Every time a user authenticates, a websocket is created and a list of online users is available.
In Firestore, I simply mark that user as "Active" when their socket is connected and "Inactive" when it's disconnected.
My problem is that the app crashes (It happens, even if it didn't, I need to plan for that.) all the users that were connected to the Go Server via web socket, are still marked as active.
Web clients aren't connected to Firebase. Only to the Go server.
I can't mark all users as inactive when the app starts up. Because multiple apps might start up because of App Engine loading more instances. If I did that, users that are online would be marked as offline by new instance booting up because of load.
How does one get around issues like this?