Skip to content

perf(forwarder): reuse boto3 S3 client across SQS batch records#1079

Merged
LorisFriedel merged 1 commit intomasterfrom
loris.friedel/perf-reuse-s3-client
Mar 17, 2026
Merged

perf(forwarder): reuse boto3 S3 client across SQS batch records#1079
LorisFriedel merged 1 commit intomasterfrom
loris.friedel/perf-reuse-s3-client

Conversation

@LorisFriedel
Copy link
Member

Summary

  • S3EventHandler._get_s3_client() created a new boto3.client("s3") per record (service model parsing, session setup, connection pool init)
  • For a 10-record SQS batch, that is 10 client constructions per invocation
  • Extract create_s3_client() as a module-level function and accept an optional s3_client parameter in S3EventHandler.__init__
  • sqs_handler() creates the client once before the loop and passes it to all handlers
  • Backward compatible: callers that omit s3_client get a client created at construction time

Test plan

  • Existing test_s3_handler.py and test_parsing.py tests pass
  • test_s3_tags_added_to_metadata updated to mock _extract_data instead of the removed _get_s3_client
  • Verify SQS-triggered S3 processing works end-to-end via integration tests

🤖 Generated with Claude Code

@LorisFriedel LorisFriedel requested a review from a team as a code owner March 16, 2026 10:29
@github-actions github-actions bot added the aws label Mar 16, 2026
@ViBiOh ViBiOh self-assigned this Mar 17, 2026
S3EventHandler._get_s3_client() created a new boto3.client("s3") per
record. For a 10-record SQS batch that means 10 client constructions
(service model parsing, session setup, connection pool init).

Extract create_s3_client() as a module-level function, accept an
optional s3_client parameter in S3EventHandler.__init__, and create the
client once in sqs_handler() before the loop.

Backward compatible: callers that omit s3_client get a client created
at construction time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@LorisFriedel LorisFriedel force-pushed the loris.friedel/perf-reuse-s3-client branch from c2b1b40 to 77e68d5 Compare March 17, 2026 10:32
@LorisFriedel LorisFriedel merged commit 74c386d into master Mar 17, 2026
10 checks passed
@LorisFriedel LorisFriedel deleted the loris.friedel/perf-reuse-s3-client branch March 17, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants