-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Describe the bug
When client is setup with connectionIdlePollingInterval, it causes delay for the response to become available.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected behavior
No additional delay regardless of the value of connectionIdlePollingInterval
Current behavior
There is an additional delay for each request which corresponds with the connectionIdlePollingInterval setting.
Steps to Reproduce
package com.example.playground
import aws.sdk.kotlin.services.s3.S3Client
import aws.sdk.kotlin.services.s3.headObject
import aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.measureTime
suspend fun main() {
val bucket = "my-bucket"
val key = "my-key"
S3Client {
region = "us-west-2"
httpClient(OkHttpEngine) {
connectionIdlePollingInterval = 500.milliseconds
}
}.use { client ->
repeat(5) {
measureTime {
client.headObject {
this.bucket = bucket
this.key = key
}
}.also { println("Request duration: $it") }
}
}
}Example output:
Request duration: 3.028859417s
Request duration: 725.529083ms
Request duration: 751.692167ms
Request duration: 722.700250ms
Request duration: 728.030250ms
Example output without connectionIdlePollingInterval:
Request duration: 2.925923958s
Request duration: 232.163250ms
Request duration: 231.357042ms
Request duration: 225.145542ms
Request duration: 236.862875ms
We can discard the first request as warmup.
Possible Solution
No response
Context
I'm trying to apply the connectionIdlePollingInterval setting to prevent intermittent connection errors on production. However, it causes noticeable delay.
In addition I think it would be nice to make the hardcoded Dispatchers.IO configurable in ConnectionMonitoringEventListener as applications often use this dispatcher for other purposes which could cause some conflicts. Alternatively, it could be configured using limitedParallelism which would create a dedicated pool for the connection monitor. Note: this probably wouldn't solve the issue in itself, this is just an additional observation that I made while debugging the issue.
AWS SDK for Kotlin version
1.5.62
Platform (JVM/JS/Native)
Java 17/21
Operating system and version
macOs 14.8.2