-
Notifications
You must be signed in to change notification settings - Fork 9.2k
doExtensiveHealthChecks based on isOneShot instead of method #8944
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
base: master
Are you sure you want to change the base?
Conversation
I'll defer to @swankjesse My concerns would be
|
Failing on formatting Run './gradlew :spotlessApply' to fix these violations. |
Thanks @yschimke I have applied the formatting changes |
Unfortunately,
Agreed that it’s expensive! We currently don’t bother for connections used within the last 10 seconds. val idleDurationNs = withLock { nowNs - idleAtNs }
if (idleDurationNs >= IDLE_CONNECTION_HEALTHY_NS && doExtensiveChecks) {
return socket.isHealthy(source)
} Is this adequate? Would bumping it to 20 or 30 seconds help? (Could you tell me a bit more about your use case?) |
@swankjesse maybe I am missing something, but I don't understand what the relevance of idempotency is here? First Idempotency determines whether a request is safe to be retried, but that is not how it is used here, consider what would happen if you had:
My understanding of the check is this should be a cost-benefit analysis on whether the extensive health check is likely to be worthwhile:
okhttp/okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/http/RetryAndFollowUpInterceptor.kt Lines 145 to 146 in d2dd180
|
I don’t think we can reliably tell whether a call on a reused connection failed before the server processed the request, or after the server processed the request. If it failed after the server processed the request, we have a correctness problem, not a performance problem. So OkHttp is trying to be conservative here. 10 seconds is probably way too conservative, and we could probably bump it to 60 seconds without problem, but also I think the net number of health checks saved by that change would be negligible. |
This PR replaces the implementation of the
doExtensiveHealthChecks()
condition, which is used to decide whether to health-check pooled connections prior to re-use.Currently the socket health check is enabled for all non-GET requests, afterwards the deep health check is only enabled for requests where isOneShot()=true.
See comment: #7007 (comment)
The docs for isOneShot say:
Why
The extensive health check is expensive, and requires a 1ms read timeout check, it should be avoided where possible.
See similar PR: #5795