question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getSignedUrl is blocking the event loop

See original GitHub issue

We have an Express.js API which is using signed URLs for managing media files (images, video and files). Some endpoints can return from 0 to many signed URLs and we are having huge problems with the performance of storage.bucket(...).file(...).getSignedUrl(...) because it is delaying the Node.js event loop (or at least this is what I think right now). The more signed URLs, the worst performance. With a very low usage, the app performance is degrading so much that it is unusable.

Using clinic.js for profiling, we get the following event loop delay times:

Screen Shot 2022-01-28 at 4 13 31 PM

and this just commenting getSignedUrl line:

Screen Shot 2022-01-28 at 4 12 51 PM

The tool is making:

  • 50 req/s calling to an endpoint
  • the endpoint is calling in parallel (await Promise.all([ ... ])) 10 times to getSignedUrl method

Environment details

  • OS: Linux
  • Node.js version: 16.6.2
  • npm version: 7.20.3
  • @google-cloud/storage version: 5.16.0

Any clue is welcome! Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
ddelgrosso1commented, Feb 2, 2022

Currently prefixes are not supported by the storage library. The documentation you had linked above is actually for Cloud CDN.

1reaction
shahmirncommented, Feb 3, 2022

Hi!

Yes, to clarify, this was with usage of getSignedUrl.

For us, it was the number of documents we were signing in “parallel” using Promise.all

For something like 3 or 4, all the promises resolved in a total of less than a second

For something like 600 calls to getSignedUrl, the promise.all was finishing in 13+ seconds.

Changing to manually setting the private key resulted in the promises to finish in ~3 to 4 seconds, which is acceptable for our use-case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ways to avoid blocking Event Loop in Node.js - Medium
Event loop allows Node.js to perform non-blocking I/O operations by offloading operations to the system kernel whenever possible.
Read more >
Why does a while loop block the event loop? - Stack Overflow
It's fairly simple really. Internally, node.js consists of this type of loop: Get something from the event queue; Run whatever task is indicated...
Read more >
Asynchronous getSignedUrl callback is not really ... - GitHub
This indicates to me that the callbacks are happening on the same tick in the event loop as the getSignedUrl function that's calling...
Read more >
Serverless Node.js and Angular S3 Uploads
js is an incredible JavaScript runtime for server based APIs. The one place it falls down is during long running event loop blocking...
Read more >
Working with Amazon S3 presigned URLs - AWS SDK for ...
Blocking some types of cookies may impact your experience of our sites. ... Using alarm actions in CloudWatch · Sending events to CloudWatch....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found