alpakka icon indicating copy to clipboard operation
alpakka copied to clipboard

S3: Expose ClientConnectionSettings.idleTimeout in S3Settings

Open an-tex opened this issue 3 years ago • 2 comments

Short description

Downloading a huge file to a slow consumer might cause a java.io.IOException: akka.stream.scaladsl.TcpIdleTimeoutException: TCP idle-timeout encountered on connection to [minio:80], no bytes passed in the last 1 minute. One way around it would be setting the ClientConnectionSettings.idleTimeout to a higher level

Details

The ClientConnectionSettings.idleTimeout can already be set system wide, but this might have an unwanted effect on other (non s3) connections. Exposing it through the S3Settings and setting it in https://github.com/akka/alpakka/blob/master/s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala#L572 would configure it only for the S3 connection pool.

There are certainly other ways like another/bigger disk/memory buffer. But especially with a self managed minio instance as the S3 endpoint and huge files it could make sense to make use of the tcp based back pressure to keep the heap/disk usage at minimum.

I'd be happy to create a PR if that sounds reasonable.

an-tex avatar Nov 20 '20 09:11 an-tex

Introducing a setting for this is reasonable.

Please note that the current poolSettings method applies only when a forward proxy is used. In all other cases the Akka HTTP default settings apply:

https://github.com/akka/alpakka/blob/a1f2cf02b4c1d822a4b1b2c240d01f4e477fd9c2/s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala#L591-L595

ennru avatar Nov 20 '20 15:11 ennru

Introducing a setting for this is reasonable.

Please note that the current poolSettings method applies only when a forward proxy is used. In all other cases the Akka HTTP default settings apply:

Thanks for the hint. As the idleTimeout being the second parameter (forwardProxy being the first) passed through to the ConnectionPoolSettings, I now wonder whether it would make sense to allow providing a complete ConnectionPoolSettings in the S3Settings ? This way the user could fine tune any pool parameter without the need to adapt the S3 alpakka connector accordingly.

an-tex avatar Nov 25 '20 10:11 an-tex