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

AWS putObject is very slow due to single byte reads in AwsChunkedDecodingInputStream #1115

Closed
risdenk opened this issue Apr 5, 2023 · 7 comments · Fixed by #1120
Closed
Assignees
Labels

Comments

@risdenk
Copy link

risdenk commented Apr 5, 2023

AwsChunkedDecodingInputStream only implements the read() method which is one byte at a time.

https://github.com/adobe/S3Mock/blame/main/server/src/main/java/com/adobe/testing/s3mock/util/AwsChunkedDecodingInputStream.java#L72

This results in slow uploads due to repeated one byte reads from the stream. A simple solution is to wrap the provided source InputStream with BufferedInputStream which avoids the repeated one byte reads.

We have a test in Apache Solr that was taking 11s to due a 10mb file upload and after this simple change results in the test taking <1s. The simple change being replace this.source = source with this.source = new BufferedInputStream(source); in AwsChunkedDecodingInputStream

https://github.com/adobe/S3Mock/blame/main/server/src/main/java/com/adobe/testing/s3mock/util/AwsChunkedDecodingInputStream.java#L68

This shows a profiler running for the test and ~80% of the samples came from AwsChunkedDecodingInputStream#read
Screenshot 2023-04-05 at 13 20 20

@afranken
Copy link
Member

afranken commented Apr 6, 2023

@risdenk thanks for opening this issue.
The fix is simple, unfortunately the S3Mock release is currently blocked due to a problem pushing images to Docker Hub. I hope to get this resolved soon.

@risdenk
Copy link
Author

risdenk commented May 10, 2023

@afranken any luck w/ the releases?

@afranken
Copy link
Member

afranken commented Jun 7, 2023

@risdenk finally got the release up and running again, just re-released the changes from January / February today.
I'll look into making the next patch release this week.

@afranken
Copy link
Member

afranken commented Jun 8, 2023

@risdenk just released 2.12.2 :)

@risdenk
Copy link
Author

risdenk commented Jun 9, 2023

Thanks @afranken!

@JJRdec
Copy link

JJRdec commented Aug 16, 2023

Hi all, I'm still seeing slow uploads. This actually results in read timeout exception on upload of large files. We are using the latest (3.1.0) release.

Are we sure this has been fixed @afranken ?

As a workaround, you can set read timeout to infinite (not ideal).

@afranken
Copy link
Member

@JJRdec Could you please open a new ticket with a description on how to reproduce the issue?

I just tested uploading a 1GB file:

truncate -s 1G output.file
aws s3 cp ./output.file s3://bucket-a/ --endpoint-url=http://localhost:9090

The upload itself is really fast, at least locally when running S3Mock and copying a 1GB file to a bucket, it uploads with 250MB/s.
AWS CLI is using a multipart upload automatically. What is taking a while is the process of merging all parts into one file during the completion of the multipart.

Please keep in mind that S3Mock is meant to be used for local integration testing.
Usually, small files are sufficient to test this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants