philips-labs / terraform-aws-github-runner

Terraform module for scalable GitHub action runners on AWS
https://philips-labs.github.io/terraform-aws-github-runner/
MIT License
2.44k stars 578 forks source link

fix(lambda): reuse http clients #3931

Open samchungy opened 3 weeks ago

samchungy commented 3 weeks ago

Creating Http Clients per request is slow, as the client always has to re-establish a new connection with AWS. Not to mention, they're actually cause for concern when it comes to memory leaks, but fortunately with Lambdas they aren't long lived enough.

This PR changes the code to create single clients so we should see noticeable improvements with successive invocations of the Lambdas.

It's best practice to initialise these outside of the handler.

npalm commented 6 days ago

Thx for creating the PR. I thought that caching was not needed anymore with v3. I will check your PR next week.

npalm commented 3 days ago

Have you seen that the canges made are breaking the tests?

samchungy commented 3 days ago

Have you seen that the canges made are breaking the tests?

Interesting, I'll take a peek when I get some time 👀