aws / aws-dax-go

AWS DAX SDK for the Go programming language. https://aws.amazon.com/dynamodb/dax
Apache License 2.0
47 stars 49 forks source link

Dial Connection not being considered by context timeout #33

Open mocyuto opened 3 years ago

mocyuto commented 3 years ago

We've ran into an issue where we set timeouts, but during high traffic/requests dax seems to not properly timeout. We setup our dax client as below...

sess := session.Must(session.NewSession())
cfg := dax.DefaultConfig()
cfg.Credentials = sess.Config.Credentials
cfg.Region = region
cfg.HostPorts = []string{endpoint}
cfg.RequestTimeout = 300 * time.Millisecond
cfg.ReadRetries = 1                    // default is 2
cfg.MaxPendingConnectionsPerHost = 100 // default is 10
cfg.DialContext = (&net.Dialer{
  Timeout:   300 * time.Millisecond,
  KeepAlive: 30 * time.Second,
}).DialContext
client := dax.New(cfg)

During peak traffic hours we are seeing dax response take over 3 seconds. I'm suspecting dial connection to be using context.TODO instead of request context.

https://github.com/aws/aws-dax-go/blob/master/dax/internal/client/tubepool.go#L318

Thank you in advance!

miparnisari commented 1 year ago

@mocyuto were you able to find the root cause or a fix for this?

BTW the right code line now is https://github.com/aws/aws-dax-go/blob/master/dax/internal/client/tubepool.go#L341

Also see https://github.com/aws/aws-dax-go/issues/46