Timing SDK operations
How to perform basic instrumentation in the AWS SDK for Go V2 to time SDK operations
We are unable to provide guidance to customers on how to configure their HTTP workflow in a manner that is most effective for their particular workload. The answer to this is the product of a multivariate equation, with input factors including but not limited to:
Much like the previous question, it depends. Elements to consider here include the following:
The answer to this question should almost NEVER be based on pure empirical observation of upstream behavior - e.g. “I made 1000 calls to this operation, it took at most 5 seconds so I will set the timeout based on that with a safety factor of 2x to 10 seconds”. Environment conditions can change, services can temporarily degrade, and these types of assumptions can become wrong without warning.
We are unable to assist with extended or timed-out operation calls due to extended time spent on the wire. “Wire time” in the SDK is defined as any of the following:
HTTPClient.Do()
methodRead()
s on an HTTP response body that has been forwarded to
the caller (e.g. GetObject
)If you are experiencing issues due to operation latency or timeouts, your first course of action should be to obtain telemetry of the SDK operation lifecycle to determine the timing breakdown between time spent on the wire and the surrounding overhead of the operation. See the guide on timing SDK operations, which contains a reusable code snippet that can achieve this.
read: connection reset
error?The SDK retries any errors matching the connection reset
pattern by default.
This will cover error handling for most operations, where the operation’s HTTP
response is fully consumed and deserialized into its modeled result type.
However, this error can still occur in a context outside of the retry loop:
certain service operations directly forward the API’s HTTP response body to the
caller to be consumed from the wire directly via io.ReadCloser
(e.g.
GetObject
’s object payload). You may encounter this error when performing a
Read
on the response body.
This error indicates that your host, the service or any intermediary party (e.g. NAT gateways, proxies, load balancers) closed the connection while attempting to read the response.
This can occur for several reasons:
io.ReadCloser
instances provided in an operation’s response, regardless of whether you
consume its contents.Beyond that, try running a tcpdump for an affected connection at the edge of your network (e.g. after any proxies that you control). If you see that the AWS endpoint seems to be sending a TCP RST, you should use the AWS support console to open a case against the offending service. Be prepared to provide request IDs and specific timestamps of when the issue occured.
The signature algorithm for AWS services (generally sigv4) is tied to the
serialized request’s headers, more specifically most headers prefixed with
X-
. Proxies are prone to modifying the outgoing request by adding additional
forwarding information (often via an X-Forwarded-For
header) which
effectively breaks the signature that the SDK calculated.
If you’re using an HTTP proxy and experiencing signature errors, you should work to capture the request as it appears outgoing from the proxy and determine whether it is different.
How to perform basic instrumentation in the AWS SDK for Go V2 to time SDK operations