Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher latency seen with pubsub publish call #441

Closed
tmatsuo opened this issue Mar 11, 2015 · 11 comments
Closed

Higher latency seen with pubsub publish call #441

tmatsuo opened this issue Mar 11, 2015 · 11 comments
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. 🚨 This issue needs some love. triage me I really want to be triaged.
Milestone

Comments

@tmatsuo
Copy link
Contributor

tmatsuo commented Mar 11, 2015

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.

@jgeewax jgeewax added perf api: pubsub Issues related to the Pub/Sub API. labels Mar 11, 2015
@jgeewax jgeewax added this to the Pub/Sub Beta milestone Mar 11, 2015
@stephenplusplus
Copy link
Contributor

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.

@tmatsuo
Copy link
Contributor Author

tmatsuo commented Mar 11, 2015

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.

@ryanseys ryanseys changed the title Higher latency when using service account Higher latency seen with pubsub publish call Mar 14, 2015
@ryanseys
Copy link
Contributor

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

@tmatsuo
Copy link
Contributor Author

tmatsuo commented Mar 17, 2015

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

@ryanseys
Copy link
Contributor

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.

@Pampattitude
Copy link
Contributor

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!

@Pampattitude
Copy link
Contributor

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

@jgeewax
Copy link
Contributor

jgeewax commented Jun 16, 2015

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

@stephenplusplus
Copy link
Contributor

@tmatsuo ?

@tmatsuo
Copy link
Contributor Author

tmatsuo commented Nov 23, 2015

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

@stephenplusplus
Copy link
Contributor

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

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
sofisl pushed a commit that referenced this issue Sep 16, 2022
gcr.io/repo-automation-bots/owlbot-nodejs:latest@sha256:f93bb861d6f12574437bb9aee426b71eafd63b419669ff0ed029f4b7e7162e3f
sofisl pushed a commit that referenced this issue Oct 5, 2022
gcr.io/repo-automation-bots/owlbot-nodejs:latest@sha256:f93bb861d6f12574437bb9aee426b71eafd63b419669ff0ed029f4b7e7162e3f
sofisl pushed a commit that referenced this issue Oct 5, 2022
gcr.io/repo-automation-bots/owlbot-nodejs:latest@sha256:f93bb861d6f12574437bb9aee426b71eafd63b419669ff0ed029f4b7e7162e3f
sofisl pushed a commit that referenced this issue Oct 8, 2022
gcr.io/repo-automation-bots/owlbot-nodejs:latest@sha256:f93bb861d6f12574437bb9aee426b71eafd63b419669ff0ed029f4b7e7162e3f
sofisl pushed a commit that referenced this issue Oct 12, 2022
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@types/sinon](https://togithub.com/DefinitelyTyped/DefinitelyTyped) | [`^9.0.0` -> `^10.0.0`](https://renovatebot.com/diffs/npm/@types%2fsinon/9.0.11/10.0.0) | [![age](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/compatibility-slim/9.0.11)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/confidence-slim/9.0.11)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

:date: **Schedule**: "after 9am and before 3pm" (UTC).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-bigquery-data-transfer).
sofisl pushed a commit that referenced this issue Oct 13, 2022
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@types/sinon](https://togithub.com/DefinitelyTyped/DefinitelyTyped) | [`^9.0.0` -> `^10.0.0`](https://renovatebot.com/diffs/npm/@types%2fsinon/9.0.11/10.0.0) | [![age](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/compatibility-slim/9.0.11)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/confidence-slim/9.0.11)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

:date: **Schedule**: "after 9am and before 3pm" (UTC).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-bigquery-data-transfer).
sofisl pushed a commit that referenced this issue Nov 10, 2022
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/ba2d388f-b3b2-4ad7-a163-0c6b4d86894f/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@05de3e1
sofisl pushed a commit that referenced this issue Nov 10, 2022
…d config for cloud-rad for nodejs (#441)

This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/91408a5a-0866-4f1e-92b1-4f0e885b0e2e/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@21f1470
Source-Link: googleapis/synthtool@388e10f
Source-Link: googleapis/synthtool@d82decc
sofisl pushed a commit that referenced this issue Nov 11, 2022
[PR](googleapis/gapic-generator-typescript#878) within
updated gapic-generator-typescript version 1.4.0

Committer: @summer-ji-eng
PiperOrigin-RevId: 375759421

Source-Link: googleapis/googleapis@95fa72f

Source-Link: googleapis/googleapis-gen@f40a343
sofisl pushed a commit that referenced this issue Nov 11, 2022
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/7d84eafd-4925-434f-9ffd-6407671972cb/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 361273630
Source-Link: googleapis/googleapis@5477122
sofisl pushed a commit that referenced this issue Nov 11, 2022
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 11, 2022
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
sofisl pushed a commit that referenced this issue Nov 17, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [uuid](https://togithub.com/uuidjs/uuid) | devDependencies | major | [`^7.0.0` -> `^8.0.0`](https://renovatebot.com/diffs/npm/uuid/7.0.3/8.0.0) |

---

### Release Notes

<details>
<summary>uuidjs/uuid</summary>

### [`v8.0.0`](https://togithub.com/uuidjs/uuid/blob/master/CHANGELOG.md#&#8203;800-httpsgithubcomuuidjsuuidcomparev703v800-2020-04-29)

[Compare Source](https://togithub.com/uuidjs/uuid/compare/v7.0.3...v8.0.0)

##### ⚠ BREAKING CHANGES

-   For native ECMAScript Module (ESM) usage in Node.js only named exports are exposed, there is no more default export.

    ```diff
    -import uuid from 'uuid';
    -console.log(uuid.v4()); // -> 'cd6c3b08-0adc-4f4b-a6ef-36087a1c9869'
    +import { v4 as uuidv4 } from 'uuid';
    +uuidv4(); // ⇨ '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
    ```

-   Deep requiring specific algorithms of this library like `require('uuid/v4')`, which has been deprecated in `uuid@7`, is no longer supported.

    Instead use the named exports that this module exports.

    For ECMAScript Modules (ESM):

    ```diff
    -import uuidv4 from 'uuid/v4';
    +import { v4 as uuidv4 } from 'uuid';
    uuidv4();
    ```

    For CommonJS:

    ```diff
    -const uuidv4 = require('uuid/v4');
    +const { v4: uuidv4 } = require('uuid');
    uuidv4();
    ```

##### Features

-   native Node.js ES Modules (wrapper approach) ([#&#8203;423](https://togithub.com/uuidjs/uuid/issues/423)) ([2d9f590](https://togithub.com/uuidjs/uuid/commit/2d9f590ad9701d692625c07ed62f0a0f91227991)), closes [#&#8203;245](https://togithub.com/uuidjs/uuid/issues/245) [#&#8203;419](https://togithub.com/uuidjs/uuid/issues/419) [#&#8203;342](https://togithub.com/uuidjs/uuid/issues/342)
-   remove deep requires ([#&#8203;426](https://togithub.com/uuidjs/uuid/issues/426)) ([daf72b8](https://togithub.com/uuidjs/uuid/commit/daf72b84ceb20272a81bb5fbddb05dd95922cbba))

##### Bug Fixes

-   add CommonJS syntax example to README quickstart section ([#&#8203;417](https://togithub.com/uuidjs/uuid/issues/417)) ([e0ec840](https://togithub.com/uuidjs/uuid/commit/e0ec8402c7ad44b7ef0453036c612f5db513fda0))

##### [7.0.3](https://togithub.com/uuidjs/uuid/compare/v7.0.2...v7.0.3) (2020-03-31)

##### Bug Fixes

-   make deep require deprecation warning work in browsers ([#&#8203;409](https://togithub.com/uuidjs/uuid/issues/409)) ([4b71107](https://togithub.com/uuidjs/uuid/commit/4b71107d8c0d2ef56861ede6403fc9dc35a1e6bf)), closes [#&#8203;408](https://togithub.com/uuidjs/uuid/issues/408)

##### [7.0.2](https://togithub.com/uuidjs/uuid/compare/v7.0.1...v7.0.2) (2020-03-04)

##### Bug Fixes

-   make access to msCrypto consistent ([#&#8203;393](https://togithub.com/uuidjs/uuid/issues/393)) ([8bf2a20](https://togithub.com/uuidjs/uuid/commit/8bf2a20f3565df743da7215eebdbada9d2df118c))
-   simplify link in deprecation warning ([#&#8203;391](https://togithub.com/uuidjs/uuid/issues/391)) ([bb2c8e4](https://togithub.com/uuidjs/uuid/commit/bb2c8e4e9f4c5f9c1eaaf3ea59710c633cd90cb7))
-   update links to match content in readme ([#&#8203;386](https://togithub.com/uuidjs/uuid/issues/386)) ([44f2f86](https://togithub.com/uuidjs/uuid/commit/44f2f86e9d2bbf14ee5f0f00f72a3db1292666d4))

##### [7.0.1](https://togithub.com/uuidjs/uuid/compare/v7.0.0...v7.0.1) (2020-02-25)

##### Bug Fixes

-   clean up esm builds for node and browser ([#&#8203;383](https://togithub.com/uuidjs/uuid/issues/383)) ([59e6a49](https://togithub.com/uuidjs/uuid/commit/59e6a49e7ce7b3e8fb0f3ee52b9daae72af467dc))
-   provide browser versions independent from module system ([#&#8203;380](https://togithub.com/uuidjs/uuid/issues/380)) ([4344a22](https://togithub.com/uuidjs/uuid/commit/4344a22e7aed33be8627eeaaf05360f256a21753)), closes [#&#8203;378](https://togithub.com/uuidjs/uuid/issues/378)

</details>

---

### Renovate configuration

:date: **Schedule**: "after 9am and before 3pm" (UTC).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#googleapis/nodejs-compute).
sofisl pushed a commit that referenced this issue Jan 10, 2023
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Jan 17, 2023
* feat: make vision helpers work with JSON proto

* lint
sofisl pushed a commit that referenced this issue Sep 14, 2023
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/9610e861-65a2-4035-85ab-1303620c4597/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@363fe30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

6 participants