Design Advice

81 views
Skip to first unread message

Joshua Smith

unread,
Jan 9, 2020, 12:31:32 PM1/9/20
to Google App Engine
I have a big app running on AppEngine standard, python 2.7.

It’s tracking analytics info from dozens of apps in the field, and I’m thinking about adding a “real time” feature, similar to what google analytics has. A web client would show inbound hits on a map as they occur, for example.

While the incoming data has some scale (not massive, typically about 4 instances), there will never be a lot of people viewing the output. 2 or 3 at a time, at most. Usually 0.

I’m wondering whether folks in this group have advice on the best approach to send a real-time data flow into the web pages.

- WebSockets seems logical, but it looks like GAE standard doesn’t support them
- I could run a websockets server somewhere else (EC2?) and somehow (?) send messages from GAE to that for distribution
- I looked at gcloud PubSub, but that seems to be more of a server->server tool than a way to send messages to web apps
- I looked at gcloud message, but that seems ill suited to use in web pages
- Polling sounds expensive, since I’d need to create lots and lots of temporary database items for the messages

Is there some other tool or technique out there that I should investigate?

-Joshua

Olu

unread,
Jan 10, 2020, 9:51:51 AM1/10/20
to Google App Engine
I think using Firebase Realtime Database to send real-time updates might be applicable in your setup and it works well with App Engine(Standard). I suggest you go through this doc[1].

Joshua Smith

unread,
Jan 10, 2020, 3:19:58 PM1/10/20
to google-a...@googlegroups.com
This looks very promising, and I’m playing with it now. Getting the permissions set up is hard, though.

At first, I simply tried to create a firebase project associated with the GAE project that’s going to dump data there. I was able to do that, but it won’t let me create a realtime database because my GAE project has a database of its own.

So then I tried creating a brand new thing. And that works, except I can’t figure out how to give my GAE project permission to read/write to it. If I try to add it’s “@appspot.gserviceaccount.com” email as a User with Editor permission, it just gives an error.

Any idea how I can give my GAE project permission to authenticate against a different Firebase project?

-Joshua

On Jan 10, 2020, at 9:51 AM, 'Olu' via Google App Engine <google-a...@googlegroups.com> wrote:

I think using Firebase Realtime Database to send real-time updates might be applicable in your setup and it works well with App Engine(Standard). I suggest you go through this doc[1].


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/602eb9d0-d46f-45cd-91dd-a59eddd0ef88%40googlegroups.com.

Joshua Smith

unread,
Jan 10, 2020, 4:09:23 PM1/10/20
to Google App Engine
And a related issue. I have some code that this app successfully uses to connect to the google analytics API. I tweaked that code for firebase as follows:

  from oauth2client.service_account import ServiceAccountCredentials
  from httplib2 import Http
  credentials = ServiceAccountCredentials.from_json_keyfile_name(
  http = Http()
  http_auth = credentials.authorize(http)

But that gives 401 errors. I would guess that I need to enabled an API on the console, but I can’t figure out which one to enable. I enabled “Firebase Storage” but that didn’t help.

What API do I need to enable to get that scope authorized?

-Joshua

Niall McCarthy

unread,
Jan 13, 2020, 7:51:00 AM1/13/20
to Google App Engine
A quick bit of guidance needed I am new to App Engine and evaluating it for a large new development. The development would have approximately
400 to 500 users initially. The main question I need to ask is the design would require a separate app engine instance and cloudsql db per user.

Does app engine support this setup should be looking Cloud Run for this any starting advice appreciated.

Pierre-Yves Blain

unread,
Jan 14, 2020, 1:16:44 PM1/14/20
to Google App Engine
Is the Analytics API enabled? Also, was the service account email address used to add a user to the analytics account you want to access via the API?
You can follow this detailed quickstart documentation [1] with explicit steps to accomplish the authorization.



On Friday, January 10, 2020 at 4:09:23 PM UTC-5, Joshua Smith wrote:
And a related issue. I have some code that this app successfully uses to connect to the google analytics API. I tweaked that code for firebase as follows:

  from oauth2client.service_account import ServiceAccountCredentials
  from httplib2 import Http
  credentials = ServiceAccountCredentials.from_json_keyfile_name(
  http = Http()
  http_auth = credentials.authorize(http)

But that gives 401 errors. I would guess that I need to enabled an API on the console, but I can’t figure out which one to enable. I enabled “Firebase Storage” but that didn’t help.

What API do I need to enable to get that scope authorized?

-Joshua
On Jan 10, 2020, at 3:19 PM, Joshua Smith <mrjoshu...@gmail.com> wrote:

This looks very promising, and I’m playing with it now. Getting the permissions set up is hard, though.

At first, I simply tried to create a firebase project associated with the GAE project that’s going to dump data there. I was able to do that, but it won’t let me create a realtime database because my GAE project has a database of its own.

So then I tried creating a brand new thing. And that works, except I can’t figure out how to give my GAE project permission to read/write to it. If I try to add it’s “@appspot.gserviceaccount.com” email as a User with Editor permission, it just gives an error.

Any idea how I can give my GAE project permission to authenticate against a different Firebase project?

-Joshua

On Jan 10, 2020, at 9:51 AM, 'Olu' via Google App Engine <google-appengine@googlegroups.com> wrote:

I think using Firebase Realtime Database to send real-time updates might be applicable in your setup and it works well with App Engine(Standard). I suggest you go through this doc[1].


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.

Joshua Smith

unread,
Jan 14, 2020, 3:15:42 PM1/14/20
to Google App Engine
This isn’t accessing analytics, it’s accessing Firebase. I just had some working code from Analytics that I used as a starting point.

Anyway, I figured it out. The trick is that I needed to create a new service account private key over on the Firebase side, download client secrets from there, and then use those secrets in the authenticated calls to firebase.

-Joshua

To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/936d054a-fb51-4fbf-b379-52692a8c1f8c%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages