getSignedUrl is blocking the event loop
See original GitHub issueWe 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:

and this just commenting getSignedUrl
line:

The tool is making:
- 50 req/s calling to an endpoint
- the endpoint is calling in parallel (
await Promise.all([ ... ])
) 10 times togetSignedUrl
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:
- Created 2 years ago
- Reactions:5
- Comments:18 (10 by maintainers)
Top 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 >
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
Currently prefixes are not supported by the storage library. The documentation you had linked above is actually for Cloud CDN.
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.