1
votes

Is it considered good practice to have my mobile clients publish messages directly to Pub/Sub?

I am looking to publish topics about user views, taps, and overall activity information directly into Pub/Sub. The volume of data inflow is quite large, so I don't want to use Cloud Functions (will overkill on no. of invocations) or Cloud Endpoints (will unnecessarily flood my logs with pretty granular activity data).

But I have been searching Google Cloud's documentation, and could not find any way to securely publish messages from frontend (web, mobile) clients. I can solve this by giving a simple service account key (that only has publishing roles), but that seems bad practice to embed account key json files into the client?

The answer to a similar question: Is it good practice to have a React Native app Publish directly to a Google Pub/Sub topic? suggested putting Pub/Sub behind Cloud Functions, which I feel would incur a lot of costs for the data I am piping through.

1
If you are concerned about the cost of Cloud Functions have you reviewed the data costs? You might be focusing on the wrong problem.John Hanley

1 Answers

2
votes

This solution paper is a fairly comprehensive answer to your question. There are others of course.

https://cloud.google.com/solutions/setting-up-a-pubsub-proxy-for-mobile-clients-on-gke