Can anyone tell following logic is possible or not:
I have one publisher and one subscriptions. I've sent 10 messages and want to ensure that each Subscriber receives 5 messages based on partitioning. Is there a way to achieve this in Google Cloud Pub/Sub? just like Kafka!
publisher (10 msg) ------> (pull) subscription ---------> subscriber 1 (5 msg) and subscriber 2 (5 msg)
Solved! Go to Solution.
Hi @Nikita_G ,
Currently, Pub/Sub does not support a built-in mechanism to ensure an exact 50/50 message distribution between two subscribers as you described. This is primarily because Pub/Sub does not use inherent partitions like Kafka, and it distributes messages based on subscriber availability and their pull rate. Additionally, it ensures at-least-once delivery, which means it targets one subscriber at a time rather than multiple simultaneously.
However, there are a few strategies you can consider to approximate this distribution:
Multiple Subscriptions with Filters: Create multiple subscriptions and use attribute-based filters to segregate messages. This doesn't guarantee an exact 50/50 split but can help with basic segregation.
Pub/Sub Lite: If you need partitioning and exactly-once delivery like Kafka, Pub/Sub Lite might be a good fit. It's cost-effective but has different performance characteristics than standard Pub/Sub.
Custom Load Balancing: Implement custom logic using Dataflow or Cloud Functions for precise control over message distribution. This is ideal for complex routing but adds complexity and maintenance overhead.
Choosing the Right Approach:
Consider your specific needs and the trade-offs of each option:
Hi @Nikita_G ,
Currently, Pub/Sub does not support a built-in mechanism to ensure an exact 50/50 message distribution between two subscribers as you described. This is primarily because Pub/Sub does not use inherent partitions like Kafka, and it distributes messages based on subscriber availability and their pull rate. Additionally, it ensures at-least-once delivery, which means it targets one subscriber at a time rather than multiple simultaneously.
However, there are a few strategies you can consider to approximate this distribution:
Multiple Subscriptions with Filters: Create multiple subscriptions and use attribute-based filters to segregate messages. This doesn't guarantee an exact 50/50 split but can help with basic segregation.
Pub/Sub Lite: If you need partitioning and exactly-once delivery like Kafka, Pub/Sub Lite might be a good fit. It's cost-effective but has different performance characteristics than standard Pub/Sub.
Custom Load Balancing: Implement custom logic using Dataflow or Cloud Functions for precise control over message distribution. This is ideal for complex routing but adds complexity and maintenance overhead.
Choosing the Right Approach:
Consider your specific needs and the trade-offs of each option:
Okay, got it! Thank you.