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

Control number of threads for downloading #111

Closed
AmandaRiu opened this issue Mar 8, 2016 · 5 comments
Closed

Control number of threads for downloading #111

AmandaRiu opened this issue Mar 8, 2016 · 5 comments
Labels
question General question

Comments

@AmandaRiu
Copy link

I'm writing a sync process on Android that grabs a list of items to download from one of our internal services, and then creates a download request for each file needed. Right now I have one project where I need to download 412 files (124.2 MB) total, and although I have this code working, I was wondering if there was a way to specify a Thread pool to use specifically for downloading so I can gain further control over simultaneous downloads?

Here is how I currently download a file:

BasicSessionCredentials awsCreds = new BasicSessionCredentials(
        creds.getAccessKeyId(),
        creds.getSecretAccessKey(),
        creds.getSessionToken());
AmazonS3Client client = new AmazonS3Client(awsCreds);

mAwsTransferUtility = new TransferUtility(client, context.getApplicationContext());

for (Object obj : downloadQueue) {
    mAwsTransferUtility.download(obj.getBucketName(), obj.getPath(), obj.getDestFile());
}
@fosterzhang fosterzhang added the question General question label Mar 8, 2016
@fosterzhang
Copy link
Contributor

Unfortunately you can't specify a thread pool. TransferUtility can do 2 downloads in parallel. Too many concurrent downloads doesn't necessarily speed things up. What's the reason you want to manage the thread pool?

@AmandaRiu
Copy link
Author

I'm getting really bad download times. Right now I'm averaging 2 minutes and 27 seconds to download 412 files totaling 124 mb. Both our iOS and Windows developers rolled their own downloader and is averaging 30 seconds to complete the download over the same pipe with comparable devices. I'm wondering what I can do to speed this up.

@fosterzhang
Copy link
Contributor

@AmandaRiu Thanks for bring this up. I see there is room for the Android SDK to improve. Stay tuned.

@fosterzhang
Copy link
Contributor

The latest release v2.2.14 has addressed this issue. The number is still not configurable. However it is set to # of cores + 1 where modern Android phones may have 4-8 cores. And we remove an unnecessary network request during download. Overall, it should speed up massive smaller downloads by 50%. See http://aws.amazon.com/releasenotes/1790148718365679

@AmandaRiu
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants