如何使用 DynamoDbAsyncClient 避免网络超时错误?

问题描述 投票:0回答:1

我在 Quarkus AWS Lambda 项目中使用异步

DynamoDbAsyncClient
。该 lambda 正在使用来自 MSK 主题的事件并处理事件并将数据更新/插入到 DynamoDB 中。
该项目被编译为本机容器映像,并且运行得非常顺利,直到一段时间后我开始看到这些错误弹出

exception:{ refId:1 exceptionType:software.amazon.awssdk.core.exception.SdkClientException message: Unable to execute HTTP request: Acquire operation took longer than the configured maximum time. This indicates that a request cannot get a connection from the pool within the specified maximum time. This can be due to high request rate. Consider taking any of the following actions to mitigate the issue: increase max connections, increase acquire timeout, or slowing the request rate. Increasing the max connections can increase client throughput (unless the network interface is already fully utilized), but can eventually start to hit operation system limitations on the number of file descriptors used by the process. If you already are fully utilizing your network interface or cannot further increase your connection count, increasing the acquire timeout gives extra time for requests to acquire a connection before timing out. If the connections doesn't free up, the subsequent requests will still timeout. If the above mechanisms are not able to fix the issue, try smoothing out your requests so that large traffic bursts cannot overload the client, being more efficient with the number of times you need to call AWS, or by increasing the number of hosts sending requests.
frames:[ 
    { class:software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl method:build line:102 } 
    { class:software.amazon.awssdk.core.exception.SdkClientException method:create line:47 }
    { class:software.amazon.awssdk.core.internal.http.pipeline.stages.utils.RetryableStageHelper method:setLastException line:204 }
    { class:software.amazon.awssdk.core.internal.http.pipeline.stages.utils.RetryableStageHelper method:setLastException line:200 }
    { class:software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncRetryableStage$RetryingExecutor method:maybeRetryExecute line:179 }
    { class:software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncRetryableStage$RetryingExecutor method:lambda$attemptExecute$1 line:159 }
    { class:java.util.concurrent.CompletableFuture method:uniWhenComplete line:863 } 
    { class:java.util.concurrent.CompletableFuture$UniWhenComplete method:tryFire line:841 }
    { class:java.util.concurrent.CompletableFuture method:postComplete line:510 } 
    { class:java.util.concurrent.CompletableFuture method:completeExceptionally line:2162 } 
    { class:software.amazon.awssdk.utils.CompletableFutureUtils method:lambda$forwardExceptionTo$0 line:76 } 
    { class:java.util.concurrent.CompletableFuture method:uniWhenComplete line:863 } 
    { class:java.util.concurrent.CompletableFuture$UniWhenComplete method:tryFire line:841 } 
    { class:java.util.concurrent.CompletableFuture method:postComplete line:510 } 
    { class:java.util.concurrent.CompletableFuture method:completeExceptionally line:2162 } 
    { class:software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage method:lambda$null$0 line:103 } 
    { class:java.util.concurrent.CompletableFuture method:uniWhenComplete line:863 } 
    { class:java.util.concurrent.CompletableFuture$UniWhenComplete method:tryFire line:841 } 
    { class:java.util.concurrent.CompletableFuture method:postComplete line:510 } 
    { class:java.util.concurrent.CompletableFuture method:completeExceptionally line:2162 } 
    { class:software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage method:lambda$executeHttpRequest$3 line:165 } 
    { class:java.util.concurrent.CompletableFuture method:uniWhenComplete line:863 } 
    { class:java.util.concurrent.CompletableFuture$UniWhenComplete method:tryFire line:841 } 
    { class:java.util.concurrent.CompletableFuture$Completion method:run line:482 } 
    { class:java.util.concurrent.ThreadPoolExecutor method:runWorker line:1136 } 
    { class:java.util.concurrent.ThreadPoolExecutor$Worker method:run line:635 } 
    { class:java.lang.Thread method:run line:833 } 
    { class:com.oracle.svm.core.thread.PlatformThreads method:threadStartRoutine line:704 } 
    { class:com.oracle.svm.core.posix.thread.PosixPlatformThreads method:pthreadStartRoutine line:202 } 
]

我正在使用 Quarkus 版本

2.13.3.Final
quarkus-amazon-services
版本
1.3.1

我尝试修改记录的 netty 参数,但没有成功。它们当前设置为:

quarkus.dynamodb.async-client.max-concurrency=200

quarkus.dynamodb.async-client.connection-timeout=30S

quarkus.dynamodb.async-client.connection-acquisition-timeout=30S

根据我的指标,我只收到非常少量的事件,我正在处理和调用

PutItem
UpdateItem

我见过的最大数量是每个 lambda 调用大约 20 个事件,所以我无法想象我发出了太多异步请求,这些请求会耗尽 Netty 内的所有连接池。是否有我可能缺少的配置细节或一些我需要确保由 Quarkus 框架执行的清理操作?

amazon-dynamodb quarkus
1个回答
0
投票

你解决过这个问题吗?现在看到同样的事情!

© www.soinside.com 2019 - 2024. All rights reserved.