GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Higher latency seen with pubsub publish call · Issue #441 · googleapis/google-cloud-node

Higher latency seen with pubsub publish call #441

New issue
Copy link
New issue
Copy link
Closed
Closed
Higher latency seen with pubsub publish call#441
Copy link
Assignees
stephenplusplus
Labels
🚨This issue needs some love.api: pubsubIssues related to the Pub/Sub API.triage meI really want to be triaged.
Milestone
Pub/Sub Beta

Description

@tmatsuo
tmatsuo
opened on Mar 11, 2015
Issue body actions

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) {

        var now = new Date().getTime();
        console.log('Calling request at ' + now);

pubsub-cmdline.js

#!/usr/local/bin/node

//var projectId = process.env.GCLOUD_PROJECT_ID; // E.g. 'grape-spaceship-123'                                                                                                                 

var projectId = 'tmatsuo-pubsub-sample';

var gcloud = require('gcloud');
var pubsub;

pubsub = gcloud.pubsub({
  projectId: 'tmatsuo-pubsub-sample',
  keyFilename: '/home/tmatsuo/secret/pubsub.json'
});

//pubsub.createTopic('gcloud-node-topic', function(err, topic) {});                                                                                                                            
var topic = pubsub.topic('gcloud-node-topic');

var message = 'howdy';
var messageObject = { data: message };

var i;
var total = 0;
var max = 0;
var N = 10;
var counter = N;

for (i = 1; i <= N; i++) {
  var callPubSub = function() {
    var now = new Date().getTime();
    console.log('Calling topic.publish at ' + now);
    topic.publish(messageObject,
                  function(err) {
                    var end = new Date().getTime();
                    var elapsed = end - now;
                    if (elapsed > max) {
                      max = elapsed;
                    }
                    total += elapsed
                    counter -= 1;
                    if (counter == 0) {
                      console.log('Average: ' + total/N);
                      console.log('Max: ' + max);
                    }
                  });
  }
  setTimeout(callPubSub, 1000 * i);
}

I'm using the released version 0.12.0.

Reacted by Mark Herhold

Activity

Next
  1. jgeewax
    added
    perf
    api: pubsubIssues related to the Pub/Sub API.
    on Mar 11, 2015
  2. jgeewax
    added this to the Pub/Sub Beta milestone on Mar 11, 2015
  3. stephenplusplus commented on Mar 11, 2015

    @stephenplusplus
    stephenplusplus
    on Mar 11, 2015
    Contributor
    More actions

    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.

  4. tmatsuo commented on Mar 11, 2015

    @tmatsuo
    tmatsuo
    on Mar 11, 2015
    ContributorAuthor
    More actions

    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.

  5. ryanseys
    changed the title [-]Higher latency when using service account[/-] [+]Higher latency seen with pubsub publish call[/+] on Mar 14, 2015
  6. ryanseys commented on Mar 17, 2015

    @ryanseys
    ryanseys
    on Mar 17, 2015
    Contributor
    More actions

    Not sure what we should do here for increasing the performance. It could be related to NodeJS performance vs. golang?

  7. tmatsuo commented on Mar 17, 2015

    @tmatsuo
    tmatsuo
    on Mar 17, 2015
    ContributorAuthor
    More actions

    Might be. Is the x2 latency expected? Do you know any good profilers to dig into such performance issue?

  8. ryanseys commented on Mar 17, 2015

    @ryanseys
    ryanseys
    on Mar 17, 2015
    Contributor
    More actions

    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.

  9. Pampattitude commented on Mar 25, 2015

    @Pampattitude
    Pampattitude
    on Mar 25, 2015
    Contributor
    More actions

    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!

  10. Pampattitude commented on Jun 15, 2015

    @Pampattitude
    Pampattitude
    on Jun 15, 2015
    Contributor
    More actions

    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 about 3000-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: 3147ms
    

    The GCE instance used for testing is a GCE g1-small instance, located in europe-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    Enabled
    

    Now, 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 :/

  11. jgeewax commented on Jun 16, 2015

    @jgeewax
    jgeewax
    on Jun 16, 2015
    Contributor
    More actions

    @tmatsuo : Any chance you can comment on this? Or loop in someone on the Pub/sub team who can?

  12. stephenplusplus commented on Nov 23, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 23, 2015
    Contributor
    More actions

    @tmatsuo ?

  13. tmatsuo commented on Nov 23, 2015

    @tmatsuo
    tmatsuo
    on Nov 23, 2015
    ContributorAuthor
    More actions

    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
    
  14. stephenplusplus commented on Nov 30, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 30, 2015
    Contributor
    More actions

    @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.

  15. 26 remaining items

  16. sofisl
    added 4 commits that reference this issue on Jan 27, 2026

    chore: reorganize kokoro configs (#441)

    7d90331

    chore: reorganize kokoro configs (#441)

    c2d242c

    build: updated kokoro config for coverage and release-please (#441)

    f2bad89

    chore: release 3.0.0 (#441)

    b53db13
  17. GautamSharda
    added a commit that references this issue on Feb 5, 2026

    chore(deps): update dependency uuid to v7 (#441)

    6554f12
  18. GautamSharda
    added a commit that references this issue on Feb 23, 2026

    chore(deps): update dependency uuid to v7 (#441)

    93f1424
  19. sofisl
    added a commit that references this issue on Feb 24, 2026

    chore: drop contributors from multiple places (#441)

    fe34ad9
  20. GautamSharda
    added a commit that references this issue on Feb 26, 2026

    chore(deps): update dependency uuid to v7 (#441)

    1687acc
  21. sofisl
    added a commit that references this issue on Feb 26, 2026

    test: fix broken tests (#441)

    2264843
  22. GautamSharda
    added 2 commits that reference this issue on Mar 11, 2026

    feat(subscription): auto close sub on non-recoverable errors (#441)

    7142af0

    build: switch to GitHub magic proxy (#441)

    967672c
  23. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    build: use per-repo publish token (#441)

    f830dce

    build: use per-repo publish token (#441)

    7144183
  24. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    build: use per-repo publish token (#441)

    e0edd79
  25. thiyaguk09
    added a commit that references this issue on May 5, 2026

    build: use per-repo publish token (googleapis#441)

    f7f166d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @stephenplusplus
    stephenplusplus

Labels

🚨This issue needs some love.api: pubsubIssues related to the Pub/Sub API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    • Pub/Sub Beta

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.