Repository navigation
Higher latency seen with pubsub publish call #441
Description
Activity
- addedapi: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.
on Mar 11, 2015 The only network call made is the publish API call. The slow start (is 178ms slow?) could be from reading and parsing your key file/wading through the deep Node call stack, as that's lazily done when the first API call needs to be made.
Thanks Stephen. I confirmed that the subsequent calls are relatively faster (updated the snippets above, and I got average ~170ms).
is 178ms slow?
Yes relatively, but if it's only the first time, it's not a big problem. Thanks for clarification.However, the actual API latency of ~170ms is slow too. When I do the same thing with golang, the average latency is around 70ms or so.
- changed the title
[-]Higher latency when using service account[/-][+]Higher latency seen with pubsub publish call[/+]on Mar 14, 2015 Not sure what we should do here for increasing the performance. It could be related to NodeJS performance vs. golang?
Might be. Is the x2 latency expected? Do you know any good profilers to dig into such performance issue?
Is the x2 latency expected?
I'm not sure. Go is pretty fast but I can't see it being 2x faster with the network in the middle.
I've tried to profile other use case before with minimal luck. NodeJS seems mediocre at best for profile-ability. I might just have not thrown enough hours at the problem.
Hi!
Are there any news on this issue?
I tried searching a bit for solutions, but can't seem to find the performance bottleneck myself.Thanks!
Hi,
Once again, high latency comes back as an issue, this time related to topic creation and subscription creation via gcloud-node.
Creating a topic takes about
3000ms, and creating an associated subscriber about3000-3200ms.Here is an example script:
'use strict'; var gcloud = require('gcloud'); var pubsub = gcloud.pubsub({ projectId: 'myAwesomeProject', }); console.time('Pub/Sub topic creation'); return pubsub.createTopic('test1', function(err, topicObj) { console.timeEnd('Pub/Sub topic creation'); console.time('Pub/Sub subscriber creation'); return topicObj.subscribe('subscriber_test1', {ackDeadlineSeconds: 600}, function(err) { console.timeEnd('Pub/Sub subscriber creation'); return process.exit(0); }); });
The results:
Pub/Sub topic creation: 2883ms Pub/Sub subscriber creation: 3147msThe GCE instance used for testing is a GCE
g1-smallinstance, located ineurope-west1-d, with the following permissions, if that helps:User info Disabled Compute Read Write Storage Full Task queue Disabled BigQuery Disabled Cloud SQL Disabled Cloud Datastore Disabled Cloud Logging Write Only Cloud Monitoring Disabled Cloud Platform EnabledNow, it is hard to know if the problem is actually the GCE instance, the Pub/Sub cloud @ GCE or the Node.js library itself from my position, but these response times are awefull nonetheless.
Would you know of any way to diagnose better this issue?
Thanks a bunch! I'm not a native english speaker, so my tone may sound rude, I hope I don't give that impression :x
[EDIT]: please note I did not provide any expected timed result or anything, because I have no idea what to compare it to. However, in the context of managed groups on GCE, it seems awefully slow and, in many cases with overcrowded REST servers, leads to even worse results and, sometimes, timeouts from the GCE load balancer.
3 seconds seems rea~lly slow :/
@tmatsuo : Any chance you can comment on this? Or loop in someone on the Pub/sub team who can?
@tmatsuo ?
Do you still see ~3000ms latency? I tested your code and it shows:
$ nodejs index.js Pub/Sub topic creation: 964ms Pub/Sub subscriber creation: 1589ms@Pampattitude - I'm going to close the issue as it appears it has resolved itself over the course of the last several months (sorry for that delay). If you're still experiencing the latency, please re-open.
26 remaining items
- added a commit that references this issue
on Feb 5, 2026 - added a commit that references this issue
on Feb 23, 2026 - added a commit that references this issue
on Feb 24, 2026 - added a commit that references this issue
on Feb 26, 2026 - added 2 commits that reference this issue
on Mar 23, 2026 - added a commit that references this issue
on Mar 27, 2026 - added a commit that references this issue
on May 5, 2026
When issuing a Cloud Pub/Sub API publish call, and I'm experiencing a higher latency than expected.
expected: 70 - 100 ms
actual: ~300 ms
To reproduce this problem, you can run the pubsub-cmdline.js (inlined at the bottom) with the small modification below. Here is an example run:
$ ./pubsub-cmdline.js
Calling topic.publish at 1426005295668
Calling request at 1426005295846
Average: 314
Max: 314
1426005295846 - 1426005295668 = 178ms
It spends more than 1/2 of the total elapsed time before issuing the actual request. I suspect that there is a unnecessary RPC (presumably GCE metadata lookup?) before the actual API call. Since I'm using the service account from the json file, there shouldn't be such RPC. Do you think of anything that causes this?
Modification gcloud/lib/common/util.js: 400
just before calling request(authorizedReqOpts, function(err, res, body) {
pubsub-cmdline.js
I'm using the released version 0.12.0.