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

LambdaAsyncClient leads to OutOfMemoryErrors under a high load #5175

Open
maxhanel opened this issue May 2, 2024 · 0 comments
Open

LambdaAsyncClient leads to OutOfMemoryErrors under a high load #5175

maxhanel opened this issue May 2, 2024 · 0 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@maxhanel
Copy link

maxhanel commented May 2, 2024

Describe the bug

The LambdaAsyncClient consumes a lot of JVM Memory and leads to an OutOfMemory Error.
Anybody a Idea, why this happens?

Expected Behavior

The LambdaAsyncClient should consume less JVM Memory.

Current Behavior

When we make requests with the Lambda Async Client, the JVM heap immediately jumps to more than 90 percent and stops at this level or the application terminates:
Terminating due to java.lang.OutOfMemoryError: Java heap space
We are using this configuration for the LambdaAsyncClient:

    @Bean
    fun createLambdaAsyncClient(): LambdaAsyncClient {
        val httpClient = NettyNioAsyncHttpClient.builder()
            .maxConcurrency(100)
            .maxPendingConnectionAcquires(100)
            .connectionTimeout(Duration.ofSeconds(10))
            .connectionMaxIdleTime(Duration.ofSeconds(5))
            .readTimeout(Duration.ofSeconds(301))
            .writeTimeout(Duration.ofSeconds(301))
            .build()

        val clientCfg: ClientOverrideConfiguration = ClientOverrideConfiguration.builder()
            .retryPolicy(RetryPolicy.defaultRetryPolicy())
            .addMetricPublisher(AwsSdkMetricPublisher(meterRegistry))
            .build()

        return LambdaAsyncClient.builder()
            .region(Region.EU_CENTRAL_1)
            .httpClient(httpClient)
            .overrideConfiguration(clientCfg)
            .build()
    }

The Invoke Request looks like this:

val response = lambdaClient.invoke(
    InvokeRequest.builder()
        .functionName(functionName)
        .payload(SdkBytes.fromByteArray(bytes))
        .invocationType(
            InvocationType.REQUEST_RESPONSE,
        ).build(),
    ).await()

Afer executing about 200 Requests the heap increases expcetionally, after that decreases, but increases in a slow way.
Screenshot 2024-05-02 at 2 05 09 PM

Reproduction Steps

I was not able to reproduce this locally.
Our application processes a queue with 100 workers. A lambda request is made at least once with every job that is processed by the queue.

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.25.34

JDK version used

jdk-17.0.9+9

Operating System and version

Linux/ARM64

@maxhanel maxhanel added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant