Skip to content

Commit

Permalink
docs: remarks on socket exhaustion warning (#6692)
Browse files Browse the repository at this point in the history
* docs: remarks on socket exhaustion warning

* docs: update for S3 streaming bodies

* docs: grammar
  • Loading branch information
kuhe authored Nov 25, 2024
1 parent 53b12f4 commit 6c297b7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions supplemental-docs/CLIENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,31 @@ new S3Client({
});
```

A note on **socket exhaustion**: if you encounter an error that indicates
A note on **socket exhaustion**:

The SDK may emit the following warning when detecting socket exhaustion:

```
@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
```

Socket exhaustion detection is not an exact determination.
We only warn on this when there is a high count of `requestsEnqueued`,
because running at socket capacity may be intentional and normal in your application.

If you encounter the above warning or an error that indicates
you have run out of sockets due to a high volume of requests flowing through
your SDK Client, there are two things to check:

1. Ensure that the number value of `maxSockets` is high enough for your
throughput needs.
2. Because `keepAlive` is defaulted to `true`, if you acquire a streaming response,
such as `S3::getObject`'s `Body` field. You must read the stream to completion
in order for the socket to close naturally.
such as `S3::getObject`'s `Body` field, you must read the stream to completion
in order for the socket to close naturally. You can also destroy the stream in Node.js with
e.g. `(await s3.getObject(...)).Body.destroy()` if it is a Node.js Readable stream.
Specifically in the case of S3, if you don't need the object body,
consider whether the object metadata can be retrieved with another operation such as
`HeadObject` or `GetObjectMetadata`.

```ts
// Example: reading a stream to allow socket closure.
Expand Down

0 comments on commit 6c297b7

Please sign in to comment.