-
I'm working on a custom file downloader using the aws rust sdk. I'm testing the performance of it versus the aws cli and noticed that I get capped at about 10-15 MiB/s download using the sdk. The aws cli is getting about up to 40 MiB/s download. I've scratched my head for a while trying figure out where performance was lost. Here is the code snippet of what I am doing in the SDK: let byte_stream = client
.get_object()
.bucket(bucket)
.key(path)
.send()
.await?
.body
.into_async_read();
let mut reader = BufReader::new(byte_stream);
let mut writer = BufWriter::new(OpenOptions::new().create(true).write(true).open(&file_path).await?);
let mut buf = vec![0; 1024]; // 1KB buffer
while let Ok(size) = reader.read(&mut buf).await {
if size == 0 {
break;
}
writer.write_all(&buf).await?;
} versus running the aws s3 cp command to a local directory. I've played around with buffer sizes and sync vs async but no luck. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
First, of course, is to double check that you're building in If you are using a new version of the CLI, the CLI is using the CRT, a C library to automatically split the download into multiple ranged GETs—the SDK does not do that automatically. You would need to write code to perform ranged GETs and use We have a code snippet in our S3 benchmark that shows how to use ranged GETs. Note that build a library for customers to do this directly is high on our priority list for 2024. We've benchmarked the Rust SDK achieving multiple Gib/S on large instance types so let me know if you're unable to match the performance. |
Beta Was this translation helpful? Give feedback.
First, of course, is to double check that you're building in
--release
. At only 10-15MiB/s this is a possible culprit.If you are using a new version of the CLI, the CLI is using the CRT, a C library to automatically split the download into multiple ranged GETs—the SDK does not do that automatically. You would need to write code to perform ranged GETs and use
write_at
to write the chunks to disk.We have a code snippet in our S3 benchmark that shows how to use ranged GETs.
Note that build a library for customers to do this directly is high on our priority list for 2024.
We've benchmarked the Rust SDK achieving multiple Gib/S on large instance types so let me know if you're unable to match…