3 ms·
Creating a boto3 client is super expensive and benefits hugely from being re-used. I see lots of code, like the examples in the post, that re-create them over a
by orf 5y ago
Creating a boto3 client is super expensive and benefits hugely from being re-used. I see lots of code, like the examples in the post, that re-create them over and over again.
- Hackbraten 5y agoThanks – good to know!
- closed 5y agoOn my laptop each run of boto3.client("s3") takes about 4 milliseconds. I'm guessing this is okay for most crud apps..! Edit: especially compared to any interactions with s3
- orf 5y ago4ms is an incredibly long time to construct an object. Under the hood it’s dynamically creating the client from JSON IDL files IIRC. At even 10 RPS it’s going to be taking a non-trivial amount of time, and I believe the connection pooling is done at the client level so you’re going to be paying for a new connection to s3 each time.