Skip to content
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

Prevent socket exhaustion in BlobStorageS3Storage #2666

Merged
merged 7 commits into from
Nov 12, 2024

Conversation

thomasdax98
Copy link
Member

@thomasdax98 thomasdax98 commented Oct 28, 2024

The relevant changes are in commits 5cb03df and a47c547

Description

Prevent socket exhaustion in BlobStorageS3Storage

Problem

By default, the S3 client allows a maximum of 50 open sockets.
A socket is only released once a file is streamed completely.
Meaning, it can remain open forever if a file stream is interrupted (e.g., when the user leaves the site).
This could lead to socket exhaustion, preventing further file delivery:

Screenshot 2024-10-25 at 11 36 27 (1)

Solution

To resolve this, the following changes were made:

  1. Added a close handler to destroy the stream when the client disconnects.
  2. Set a 60-second requestTimeout to close unused connections.

Changeset

  • I have verified if my change requires a changeset

Related tasks and documents

https://vivid-planet.atlassian.net/browse/COM-1229

Further information

The change from ReadableStream to Readable in the BlobStorageBackendInterface is not a breaking change because Readable implements ReadableStream:

Bildschirmfoto 2024-11-07 um 00 05 18

TODO

  • Backport to v6

@thomasdax98 thomasdax98 force-pushed the add-timeout-for-s3-blob-storage branch 5 times, most recently from 389cc62 to e40c190 Compare November 6, 2024 22:59
@thomasdax98 thomasdax98 changed the title Draft: Add timeout for s3 blob storage Prevent socket exhaustion in BlobStorageS3Storage Nov 6, 2024
@thomasdax98 thomasdax98 force-pushed the add-timeout-for-s3-blob-storage branch from 2dd76b3 to f7ef856 Compare November 6, 2024 23:08
@thomasdax98 thomasdax98 marked this pull request as ready for review November 6, 2024 23:11
@thomasdax98 thomasdax98 force-pushed the add-timeout-for-s3-blob-storage branch from f7ef856 to a2b6d81 Compare November 6, 2024 23:26
@johnnyomair johnnyomair removed the request for review from nsams November 12, 2024 11:51
@thomasdax98 thomasdax98 merged commit af892c1 into main Nov 12, 2024
11 checks passed
@thomasdax98 thomasdax98 deleted the add-timeout-for-s3-blob-storage branch November 12, 2024 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants