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.

generate_presigned_url is 3x as slow as boto2 for s3 resources

See original GitHub issue

When calling generate_presigned_url on a s3 resource, the resulting calls are 3x as slow as the boto2 equivalent…

In [1]: import timeit
In [7]: setup = '''
   ...: import boto3
   ...: from boto.s3.connection import S3Connection
   ...: b3_conn = boto3.client('s3')
   ...: b2_conn = S3Connection(None, None)
   ...: '''
In [13]: print min(timeit.Timer('b2_conn.generate_url(3600, "GET", bucket="foo-bucket", key="foo-key", query_auth=True)', setup=setup).repeat(7, 10000))
1.95865702629
In [14]: print min(timeit.Timer('b3_conn.generate_presigned_url("get_object", Params={"Bucket": "foo-bucket", "Key": "foo-key"}, ExpiresIn=3600, HttpMethod="GET")', setup=setup).repeat(7, 10000))
5.69024801254

This was run on c3.xlarge instances in us-west-2.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
Dizzzmascommented, Oct 19, 2020

Ran into this problem today. Found it really frustrating, as it was increasing the response time of my API endpoint by 3-4 seconds which was rather significant. And I was generating URLs for only ~30 objects.

Any news on this being addressed in the near future?

2reactions
pabdelhaycommented, Apr 15, 2021

I had the same problem. Solved by setting AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY.

When I migrate my servers to ECS it was no longer necessary to use AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY, since everything was on the same security layer. But when I removed those credentials, my application starts performing low on generating_presigned_url from S3. The solutions was to rollback and set those credentials (AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY) again even it is not mandatory on my new environment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Presigned URLs — Boto3 Docs 1.26.33 documentation - AWS
A presigned URL is generated by an AWS user who has access to the object. The generated URL is then given to the...
Read more >
Pre signed aws s3 url slowness - Stack Overflow
I am trying to secure s3 resources and i have created temporary credential using sts service in the same region where bucket exist...
Read more >
Sharing objects using presigned URLs - AWS Documentation
Generating a presigned URL to share an object. You can generate a presigned URL for an object without writing any code by using...
Read more >
Bulk Generate Pre-Signed URLs boto3 - DevAsking
Instead, whenever your application wishes to reference a resource (eg ... on a s3 resource, the resulting calls are 3x as slow as...
Read more >
Access files from AWS S3 using pre-signed URLs in Python
Generate pre-signed URLs for S3 objects in Python · 1. Generating pre-signed URL for download · 2. Generating pre-signed URL for upload; Oops:...
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