We're internally using pubsub (and nats) sending billions of messages every day. We don't use the push mode as Spotify [0] but pull from the queue instead which allows us to run on our pace.
We do write into bigquery (and citus) and each components is doing it on their own pace based on what they're capable of process at the moment.
[0] https://labs.spotify.com/2017/11/20/autoscaling-pub-sub-cons...
Request -> load balancer -> auto scaled pubsub writer -> pubsub -> client (write to BQ, ...)
If it doesn't have to be a post request, then you could just write into pubsub directly. Pubsub has a wide support of libraries [0] so you could do it from any language. Pubsub also scales well. We're sending in around 300k messages per sec and have very few problems with it.
[0] https://cloud.google.com/pubsub/docs/reference/libraries
I did think about doing something like transforming the POST in AWS Lambda (the emitter data is hosted there too) and transform into something I can ingest direct into pub/sub.
I can't control the emitting data. if I did it would be a much easier problem, each POST request contains very little data if there were multiple entries per single POST it would solve most of my problems, instead of sending 5k tiny JSON posts /sec lol
Request -> gae -> pubsub -> dataflow to bq template.
https://cloud.google.com/dataflow/docs/templates/provided-te...
We’re slowly transitioning to nats as we have a better control over what’s happening there. Also we had no issues with stability which I can’t say about pubsub
Counter-intuitively, ending the response before processing the data may actually be hurting your p99 response time. According to [3], instances which are not currently handling a request get very little CPU and generally don't make any progress. This means that this work will still be waiting to be done when the next request comes in and can slow it down. You may even end up with an instance trying to process several requests' data and also trying to handle another request on top of that. This last request is going to get an overloaded instance and likely be very slow. Further, the function isn't guaranteed to ever be run again, so that deferred work might not even ever happen.
It probably will cause you to use more of your invocations per 100 seconds quota, but you really shouldn't start background processing tasks in a Google Cloud Function that continue after completing a request.
[1] https://cloud.google.com/functions/quotas [2] https://issuetracker.google.com/issues/new?component=187195&... [3] https://cloud.google.com/functions/docs/bestpractices/tips
Interesting and thanks I had no idea on the end response CPU time. It's just storing the json to Google Cloud Storage but it does take 100-300ms it seems!
It's also why I think that Facebook never joined the rat race. Most of what they do has no relevance to the average company.
Amazon, an online retailer, was really the most natural place to start an outsourcing of banal technologies for the largest market segment. And has grown from there.
I have ran into scale problems very fast at Google and now am having to use App Engine and add more complication which I don't have personal engineering skill/capacity.
Google support first bumped me up to 12000 max queries per 100 seconds and said that's the limit, but that's not close to enough. We have super bursty traffic (webhooks that aren't concatenated from source).
Google then increased to 100,000 per 100 seconds after they claimed 12k was maximum.
It's still not enough and I think their sampling might be funky because when I look at the invocation/traffic graphs it doesn't align with the stated maximum (still throws quota errors).
Kind of frustrating. The idea of stateless functions without worrying about engineering is a dream! I don't get why Google can't get 'google scale' here. In the past we've used Snowplow on AWS when we had engineering help but that's a huge amount of work/engineering time. The actual accept POST, store to cloud storage, insert to DB is less than 100 rows.
Response time is also pretty bad in the extreme cases. Even though I end the response before processing data I still see 95%/99% spikes when bursting on the far less bursty data source (as in only bursting to 10/second). Just today for this function I got 3764ms 99%!