如何解决无法执行 HTTP 请求:获取操作花费的时间超过了配置的最长时间
我正在 AWS 中运行一个批处理作业,它使用来自 SQS 队列的消息并使用 akka 将它们写入 Kafka 主题。我使用以下参数创建了一个 Sqs 异步客户端:
private static SqsAsyncclient getSqsAsyncclient(final Config configuration,final String awsRegion) {
var asyncHttpClientBuilder = NettyNioAsyncHttpClient.builder()
.maxConcurrency(100)
.maxPendingConnectionAcquires(10_000)
.connectionMaxIdleTime(Duration.ofSeconds(60))
.connectionTimeout(Duration.ofSeconds(30))
.connectionAcquisitionTimeout(Duration.ofSeconds(30))
.readTimeout(Duration.ofSeconds(30));
return SqsAsyncclient.builder()
.region(Region.of(awsRegion))
.httpClientBuilder(asyncHttpClientBuilder)
.endpointOverride(URI.create("https://sqs.us-east-1.amazonaws.com/000000000000")).build();
}
private static SqsSourceSettings getSqsSourceSettings(final Config configuration) {
final SqsSourceSettings sqsSourceSettings = SqsSourceSettings.create().withCloSEOnEmptyReceive(false);
if (configuration.hasPath(ConfigPaths.SqsSource.MAX_BATCH_SIZE)) {
sqsSourceSettings.withMaxBatchSize(10);
}
if (configuration.hasPath(ConfigPaths.SqsSource.MAX_BUFFER_SIZE)) {
sqsSourceSettings.withMaxBufferSize(1000);
}
if (configuration.hasPath(ConfigPaths.SqsSource.WAIT_TIME_SECS)) {
sqsSourceSettings.withWaitTime(Duration.of(20,SECONDS));
}
return sqsSourceSettings;
}
但是,在运行我的批处理作业时,我收到以下 AWS 开发工具包异常:
software.amazon.awssdk.core.exception.SdkClientException: 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
以前有人遇到过这个问题吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。