Putting objects from macOS is slower than Windows #2657
-
ProblemI'm working on a software for mac OS that reads text files in S3 bucket, processes them, and uploads and updates them periodically. However, the time required for uploading is too slow to keep up with the frequency of updates. I modified put_object sample source and got these results.
However, uploading files with curl library (not to S3 bucket) on mac is not so slow as aws sdk. (It takes about 100-150 ms to upload the same text file) Is there any idea to improve upload speed? Enviroment
Code samplemodified put_object.cpp with measuring upload time. int64_t currentTimeMillis() {
static int64_t correction = 0;
#if defined(_WIN32)
struct _timeb t;
_ftime(&t);
correction = (((int64_t) t.time) * 1000 + t.millitm);
#else
struct timeval tv;
struct timezone tz;
gettimeofday(&tv, &tz);
correction = (((int64_t) tv.tv_sec) * 1000 + tv.tv_usec / 1000);
#endif
return correction;
}
class ElapsedTime {
public:
ElapsedTime() { reset(); }
virtual ~ElapsedTime() {}
void reset() { mStartMS = currentTimeMillis(); }
int64_t get() const { return currentTimeMillis() - mStartMS; }
private:
int64_t mStartMS;
};
int main() {
Aws::SDKOptions options;
Aws::InitAPI(options);
{
//TODO(user): Change bucket_name to the name of a bucket in your account.
const Aws::String bucket_name = "<my-bucket-name>";
//TODO(user): Create a file called "my-file.txt" in the local folder where your executables are built to.
const Aws::String object_name = "sample.txt";
Aws::Client::ClientConfiguration clientConfig;
// Optional: Set to the AWS Region in which the bucket was created (overrides config file).
clientConfig.region = "<my-bucket-region>";
ElapsedTime timer;
AwsDoc::S3::PutObject(bucket_name, object_name, clientConfig);
std::cout << "Upload Time: " << timer.get() << " ms" << std::endl;
}
Aws::ShutdownAPI(options);
return 0;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@github-actions proposed-answer Thank you very much for your submission. First of all if you would like to see improvement in speed performances for object upload I would highly recommend you using the S3 CRT Client (see). This might be a good workaround for you. There are multiple reasons why you can witness speed performance differences that would be proper to your environment. I'll attempt to reproduce this to see if I can notice a difference in speed performances on my end. I also wanted to share this general documentation to troubleshoot slow speeds when downloading/uploading to Amazon s3 : https://repost.aws/knowledge-center/s3-troubleshoot-slow-downloads-uploads Best regards, Yasmine |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@github-actions proposed-answer
Hello @ShimYama ,
Thank you very much for your submission.
First of all if you would like to see improvement in speed performances for object upload I would highly recommend you using the S3 CRT Client (see). This might be a good workaround for you.
There are multiple reasons why you can witness speed performance differences that would be proper to your environment. I'll attempt to reproduce this to see if I can notice a difference in speed performances on my end.
I also wanted to share this general documentation to troubleshoot slow speeds when downloading/uploading to Amazon s3 : https://repost.aws/knowledge-center/s3-troubleshoot-slow-downloads-uploads
B…