cslb icon indicating copy to clipboard operation
cslb copied to clipboard

Make dial timeout configurable

Open jenskueper opened this issue 1 year ago • 1 comments

Summary

Allow configuration of the Dialer timeout in the cslb package. The current default of 30 seconds is excessively long in HTTP contexts, delaying failover to alternative targets when one becomes unreachable or goes offline.

Ref: https://github.com/markdingo/cslb/blob/main/cslb.go#L139

Problem Statement

Currently, the cslb library uses a default timeout of 30 seconds for its net.Dialer configuration:

netDialer := &net.Dialer{
    Timeout:   30 * time.Second,
    KeepAlive: 30 * time.Second,
    DualStack: true,
    Resolver:  net.DefaultResolver,
}

In an HTTP context, this prolonged timeout significantly affects the ability to quickly retry or failover to another target when a connection fails. This results in poor user experience, degraded application performance, and longer recovery times in case of target unavailability.

There is no configuration option to override this timeout, forcing all users to accept the default value. This limitation makes the library less flexible and unsuitable for low-latency use cases.

Proposed Solution

Introduce a configuration parameter to allow users to set the Dialer.Timeout value according to their needs. This config option could be part of a cslb.EnableWithOptions call where the dial context can be configured.

jenskueper avatar Dec 11 '24 10:12 jenskueper

I think this will probably roll into however #4 is resolved.

markdingo avatar Dec 29 '24 00:12 markdingo