Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move SDK http client to CRT #1092

Closed
jeromevdl opened this issue Mar 16, 2023 · 28 comments
Closed

Move SDK http client to CRT #1092

jeromevdl opened this issue Mar 16, 2023 · 28 comments
Assignees
Labels
enhancement New feature or request priority:2 High - core feature or affects 60% of the users v2 Version 2
Milestone

Comments

@jeromevdl
Copy link
Contributor

jeromevdl commented Mar 16, 2023

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
As the CRT http client is now available (https://aws.amazon.com/blogs/developer/announcing-availability-of-the-aws-crt-http-client-in-the-aws-sdk-for-java-2-x/), we could use it in the modules we use the SDK (Parameters, Idempotency, SQS, CloudFormation) to reduce the cold start and latency.

Due to the scale, we should do this on one module first for review, and then go from there. Idempotency would be a good candidate.

Describe alternatives you've considered
N/A

Additional context
N/A

@codesometech
Copy link

@jeromevdl @msailes I can pick this up

@jeromevdl
Copy link
Contributor Author

I think this should be tagged v2. It's not really a breaking change as it's internal but it introduces a new library and quite a new way of doing things (asynchronous).

@jreijn
Copy link
Contributor

jreijn commented Jul 21, 2023

I would like to pick this up if possible? I guess changes for this have to be made against the v2 branch?

@jeromevdl
Copy link
Contributor Author

Hi @jreijn , we're not yet ready for this.

@scottgerring
Copy link
Contributor

We've setup the v2 branch so that we're ready to start taking v2 contributions ( #1337 ) and we can start working on this. Following on from What Eleni linked, we'll want to set this up so that common initialization of the clients can be configured in one place in the core module. That is - we should see if we can have one place that does stuff like setting User-Agent, region configuration, etc.), and so on, rather than duplicating this everywhere. This would have to work without coupling powertools-core onto all of the other SDKs of course.

Speaking with @jeromevdl , we think this is going to be a big, cross-cutting change, because CRT imposes async on everything. We'd love to see a single module setup with it, so we have a point of discussion, rather than big-banging the whole thing.

@jreijn are you still interested in helping here?

@jreijn
Copy link
Contributor

jreijn commented Aug 7, 2023

@scottgerring yes, I would still like to work on this. Not sure if there is any time planning for the release of v2 as I will be out for the next 2.5 weeks. Otherwise I will continue with my work on this after my vacation.

I agree with taking it single step by step, so we can discuss while moving forward.

@scottgerring
Copy link
Contributor

Hey @jreijn , we'd like to get a bit more definitive with our release planning, but I don't think that being off for a few weeks now makes a difference! Can you reach out when you are back? Suggest we have a quick kick-off chat. Will start having a think about this in the meantime.

Enjoy the break!

@msailes
Copy link
Contributor

msailes commented Aug 15, 2023

Lets watch this issue in the AWS SDK for Java v2 aws/aws-sdk-java-v2#3343

@scottgerring
Copy link
Contributor

@msailes do you have any insight into the priority of this?

@scottgerring
Copy link
Contributor

scottgerring commented Aug 15, 2023

If we decide we want to do it sync, we could do all of the geting inside of PT itself, rather than exposing futures out. That way we don't change interface to migrate to a future sync interface in the CRT later.

@msailes
Copy link
Contributor

msailes commented Aug 15, 2023

I think that would be the best approach.

@scottgerring scottgerring added the priority:2 High - core feature or affects 60% of the users label Oct 10, 2023
@scottgerring
Copy link
Contributor

Hey @jreijn , are you still interested on working on this? If not no stress at all - I will see if we can get someone else to pick it up - we've ramped up work on v2 in the last month and this will be an important bit in the middle.

@jreijn
Copy link
Contributor

jreijn commented Nov 17, 2023

@scottgerring yes I am! I'll try to synch with the work that has been done for v2 and come up with some ideas so we can discuss solutions. WDYT?

@jeromevdl
Copy link
Contributor Author

Sounds good, let us know if you have question, feel free to write down your first ideas here in this issue. You should start with the Large Message module as it's not currently refactored (parameters, idempotency are).

@jreijn
Copy link
Contributor

jreijn commented Nov 23, 2023

I've started looking at the large messages module as @jeromevdl suggested and and while trying to support the async crt client I already hit a bump which probably needs to get fixed first before moving forward. The large messages module uses an amazon library for payload offloading. It leverages s3, but only supports a synch client as far as I can see. See awslabs/payload-offloading-java-common-lib-for-aws#17

@scottgerring
Copy link
Contributor

Hey @jreijn I think best case here we get that PR merged into upstream. I will chase it up today!

@scottgerring
Copy link
Contributor

Hey @jreijn i've got the attention of the maintainers internally to try and push this and will hopefully have some news on this soon. The PR itself needs to be rebased onto the current main of the repo so its a bit more effort than initially expected.

I am torn between working on this - updating the PR on payload-offloading-java-common-lib-for-aws and finishing my open branch on #1402 . This is close to completion and is also a module that uses the SDK and could be used to prove out the path with the CRT while we wait for the payload offloading library.

@jeromevdl / @jreijn - what do you both think?

@scottgerring
Copy link
Contributor

Since writing the previous comment i've got a new PR into the payload offloading library using Richard's changes with the latest there from master. I've not tested it, i've just done the mechanical process of resolving the merge issues and fixing the tests, but I will see if we can get some eyes on it over there, and move back onto the parameters merge.

awslabs/payload-offloading-java-common-lib-for-aws#50

@jreijn
Copy link
Contributor

jreijn commented Dec 8, 2023

Most of the current modules provide some sort of Config or Manager object that supports providing a custom client.

See for instance (

)

I'm wondering if we want to switch all these methods over to only providing an async client or do we want to support both? What are your thoughts on this?

@scottgerring
Copy link
Contributor

My gut feeling is we should use the CRT everywhere and ditch the sync clients; we should encourage best practices, and this would also reduce complexity in the codebase & interface (vs supporting both).

@msailes @jeromevdl what do you both think - ?

@msailes
Copy link
Contributor

msailes commented Dec 11, 2023

The CRT client is the fastest and lowest memory HTTP client. If we can incorporate it into Powertools with a good DX / API I think we absolutely should.

@scottgerring
Copy link
Contributor

Good morning @jreijn; now that we've merged #1402 into v2, we have a reasonable sized chunk of code that uses the AWS SDK clients you could use as a testbed, instead of the large message handling !

@msailes
Copy link
Contributor

msailes commented Dec 15, 2023

aws/aws-sdk-java-v2#3343 (comment)

Good timing

@jreijn
Copy link
Contributor

jreijn commented Dec 16, 2023

@msailes @scottgerring @jeromevdl this raises an interesting question. Do we still want to go async as the sync client can be used as is I guess.

@jeromevdl
Copy link
Contributor Author

Now that sync is available I think it's easier than playing with Future everywhere. @scottgerring agree?

@scottgerring
Copy link
Contributor

My personal gut feeling is sync makes more sense for PT now that we have it; general use case for Lambda workloads is unlikely to be firing up a pile of async work and waiting on it, and the ergonomics of sync are going to be better 💘

@scottgerring
Copy link
Contributor

In #1541 we decided that the CRT will not be the default client in v2. This is because the default configuration of the client leads to a larger Lambda size, which decreases startup time. It is possible to configure our Lambda build to avoid this, but as it is more complex for the user we will document it as a optimization rather than making it the default getting-started experience.

@scottgerring scottgerring moved this from Backlog to Working on it in Powertools for AWS Lambda (Java) Feb 29, 2024
jreijn added a commit to jreijn/powertools-lambda-java that referenced this issue Mar 14, 2024
jreijn added a commit to jreijn/powertools-lambda-java that referenced this issue Mar 17, 2024
scottgerring added a commit that referenced this issue Mar 21, 2024
* chore(v2): document use of aws-crt-client (#1092)

* Update docs/FAQs.md

Co-authored-by: Jérôme Van Der Linden <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Jérôme Van Der Linden <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Jérôme Van Der Linden <[email protected]>

* chore(v2): improve documentation based on feedback (#1092)

* Update docs/FAQs.md

Co-authored-by: Scott Gerring <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Scott Gerring <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Scott Gerring <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Scott Gerring <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Scott Gerring <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Scott Gerring <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Scott Gerring <[email protected]>

* Update docs/FAQs.md

Co-authored-by: Scott Gerring <[email protected]>

* Update FAQs.md and set version

---------

Co-authored-by: Jérôme Van Der Linden <[email protected]>
Co-authored-by: Scott Gerring <[email protected]>
@scottgerring
Copy link
Contributor

As part of #1092 we have updated the documentation in v2 to reflect the above - CRT client will not be the default for the moment, but we now clearly document how to set it up.

@scottgerring scottgerring added the status/staged-major-release This change will go with the next major release label Mar 21, 2024
@jeromevdl jeromevdl removed the status/staged-major-release This change will go with the next major release label Sep 2, 2024
@jeromevdl jeromevdl moved this from Working on it to On hold in Powertools for AWS Lambda (Java) Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:2 High - core feature or affects 60% of the users v2 Version 2
Projects
Status: On hold
Development

No branches or pull requests

5 participants