News for hackers. Stuff that matters.
Re:How much is Spotify paying Google Cloud? by dmytton on Monday March 07, 2016 @05:49PM (#11242377)
Batching doesn't make any difference to the pricing:

> Batched calls are accounted for as multiple operations.

https://cloud.google.com/pubsub/pricing

Re:How much is Spotify paying Google Cloud? by patrickmclaren on Monday March 07, 2016 @07:57PM (#11242887)
Note by "queuing and batching" Spotify may be aggregating events client-side. Given that messages are priced in 64K increments, it would be most cost efficient to to get each message as close to 64K as possible.

i.e.

  # serialized: 1 message, 1 op
  publish("['foo', 'bar']")
  
  # instead of:
  
  # a) 2 messages, 2 ops
  publish("foo")
  publish("bar")
  
  # b) 2 messages, 1 call, 2 ops
  publish("foo", "bar")
Re:How much is Spotify paying Google Cloud? by dmytton on Tuesday March 08, 2016 @02:02AM (#11243911)
Yes then it would be down to their consumers to split them out. However, the graphs Spotify show from Google's monitoring do not support this and they show the actual volume of messages as quoted in the article.
Re:How much is Spotify paying Google Cloud? by patrickmclaren on Tuesday March 08, 2016 @11:28AM (#11246261)
I agree that the current graphs from Spotify don't support this. They do seem to show a one-to-one mapping between events and messages emitted. Given the comparison in my GP, I think that client-side message collation/aggregation would be a natural next step.
Re:How much is Spotify paying Google Cloud? by falsedan on Monday March 07, 2016 @07:21PM (#11242770)
I think what people are proposing is that instead of:

    64 1k messages for Events, sent individually or in a batch
they suggest:

    1 64k message for BatchedEvent
Re:How much is Spotify paying Google Cloud? by dmytton on Tuesday March 08, 2016 @02:01AM (#11243907)
That doesn't match the graphs Spotify post in their blog post. If the batch gets split out into individual operations then Google still prices for each message and each message gets delivered to the consumer. If it's just a single message that'd show up as a single message as far as Google is concerned, which is not what the Spotify test is showing.
Re:How much is Spotify paying Google Cloud? by i0exception on Monday March 07, 2016 @06:16PM (#11242491)
Yes, but if I'm reading their blog post correctly, their individual messages are much smaller than 64K

"Pub/Sub passed the test with flying colours. We published 2M messages without any service degradation and received almost no server errors from the Pub/Sub backend. Enabling batching and compression on the Event Service machines resulted in ~1Gbps of network traffic towards Pub/Sub."

Re:How much is Spotify paying Google Cloud? by dmytton on Monday March 07, 2016 @06:36PM (#11242584)
Yes, but that has no impact on the cost. It's a flat rate in 64kb blocks. Batching and compression would only affect the networking fees from Google, not the per API call fees. If you batch up 64 1kb messages into a single batch then Google still bills you for 64 publish API calls.
Re:How much is Spotify paying Google Cloud? by sharpy on Monday March 07, 2016 @06:49PM (#11242635)
They are wrapping small events into fewer larger ones. Hence the word batching.

I have 64 1k messages? Ok, I am going to put them inside a single 64k message and reduce my request count by 64x, and profit!

Re:How much is Spotify paying Google Cloud? by foota on Monday March 07, 2016 @07:19PM (#11242759)
"Batched calls are accounted for as multiple operations." - https://cloud.google.com/pubsub/pricing
Re:How much is Spotify paying Google Cloud? by sharpy on Monday March 07, 2016 @07:58PM (#11242892)
Right.

If you look at the API, the publish API allows you to push multiple messages in a single API call, and if that is the batching - publishing multiple messages - then yes, you and others are absolutely correct that there is no cost benefit.

But rather than publishing

{ "messages" : [ { message 1 }, { message 2 } ] }

You publish

{ "messages" : [ { container message containing both, still less than 64k } ] }

Then you've reduced your operations count by half. Cloud services like this have a per message overhead, for things like auditing and delivery tracking, which is why the pricing model is what it is.

If you are ok with having to unpack and process multiple messages at once as I've described, then it's a way to optimize against the pricing model.

Re:How much is Spotify paying Google Cloud? by dmytton on Tuesday March 08, 2016 @02:04AM (#11243917)
The Spotify graphs from Google's monitoring support the numbers I quoted. They may well be batching but Google is seeing (and billing) the numbers I quoted.
Re:How much is Spotify paying Google Cloud? by foota on Monday March 07, 2016 @09:47PM (#11243264)
That makes sense. Thanks. Do you see anything saying they're doing this?
Re:How much is Spotify paying Google Cloud? by Gigablah on Monday March 07, 2016 @07:58PM (#11242893)
He's talking about a single call containing multiple messages in their own serialization format.
Re:How much is Spotify paying Google Cloud? by i0exception on Monday March 07, 2016 @09:38PM (#11243233)
If 2M requests result in 1 Gb network traffic, each message is 500 bits (~60 bytes). Theoretically, that's 1K messages per batch.

Even if practically that number is much lower (around 100 per batch), the cost ends up becoming around $3,000 for the messages and $9,000 for the network, so roughly $12,000 per month.

Re:How much is Spotify paying Google Cloud? by CaveTech on Monday March 07, 2016 @06:15PM (#11242485)
Batching could mean they're aggregating calls prior to handing then off to google as a single request. If you have 64k minimum block size (guessing) you can stuff in many small requests before sending them off.
Re:How much is Spotify paying Google Cloud? by dmytton on Monday March 07, 2016 @06:38PM (#11242594)
Right but that only affects networking costs, because the batch is split out into individual publish API calls on Google's side, and that's what you're billed for.