Latency issues with Pub / Sub service
See original GitHub issueHello everyone, I am using the GCP Pub / Sub service, but I am having a problem using it, since in 15 minutes it is only able to process the sending of 20 thousand messages and I would like to know why this is happening … yes This service is supposed to process millions of events per second, the following lines of code are what I use to be able to send the messages.
This method call my function.
private async Task ProcessNotification(IEnumerable<NotificationPush> notifications)
{
await notifications.ParallelForEachAsync(async m => {
var notification_id = GenerateNotificationId();
var sent_date = _dateService.GetDate();
var notification_message = new NotificationMessage
{
rp_notification_id = notification_id,
rp_sequential_id = m.id_sequencial,
register_date = sent_date,
message = m.notification.body,
uuid = m.uuid,
application = m.application_code,
rp_campaign_id = m.campaign_id,
sent_date = sent_date
};
try
{
await _pubSubService.PublishToTopic(notification_message);
}
catch (Exception)
{
throw;
}
}, maxDegreeOfParallelism: 200);
}
This implementation method.
public async Task PublishToTopic<T>(T model)
{
var topicName = new TopicName(_configuration["GCP_ProjectId"], _configuration["GCP_TopicId"]);
var _publisherClient = await CreateClient();
var json = JsonConvert.SerializeObject(model, Formatting.None);
var data = string.Join("\n", json);
var message = new PubsubMessage()
{
Data = ByteString.CopyFromUtf8(data)
};
var response = await _publisherClient.PublishAsync(topicName, new List<PubsubMessage> { message });
}
This my connection method.
public async Task<PublisherClient> CreateClient(TopicName topicName)
{
var isWebApp = _configuration["isWebApp"];
var binDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var rootDirectory = Path.GetFullPath(Path.Combine(binDirectory, ".."));
var config = Path.Combine(rootDirectory, "authgcp.json");
GoogleCredential credential = null;
using (var jsonStream = new FileStream(config, FileMode.Open, FileAccess.Read, FileShare.Read))
credential = GoogleCredential.FromStream(jsonStream);
PublisherServiceApiClient publisherService = await new PublisherServiceApiClientBuilder { ChannelCredentials = credential.ToChannelCredentials() }.BuildAsync();
_client = publisherService;
return _client;
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (1 by maintainers)
Top Results From Across the Web
python - Latency under low traffic in Google PubSub
There can be several factors that impact latency of low-throughput Pub/Sub streams. First of all, the publish-side client library does wait ...
Read more >Pub/Sub: Introduction to reliability
To minimize latency in the event that cost is not a concern, then the best strategy is to always publish and subscribe simultaneously...
Read more >Pub/Sub Best Practices: Latency & Reliability - YouTube
Delivery latency health score 1:31 - 5. Pub / Sub metrics dashboards 2:08 - 6. Quota alerts 2:29 - Wrap up Pub /...
Read more >Pub/Sub Horrible Latency for Pull Subscription
Create a pull subscription to that same topic. I set up a 10 second acknowledgement deadline, 7 day retention but not retain acknowledged ......
Read more >Benchmarking Kafka and Google Cloud Pub/Sub Latencies
I defined latency as the time elapsed from when a message is published and when it's received by a subscriber. I didn't count...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jskeet I’m going to try to send it in batches as you suggest, but I would like to know what is the limit of messages that can be sent in the following code …
await _publisherClient.PublishAsync(topicName, new List<PubsubMessage> { message });
Right, glad to hear it - will close this.