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

Docker pull/push with max concurrency limits. #22445

Merged
merged 1 commit into from
May 12, 2016

Conversation

yongtang
Copy link
Member

@yongtang yongtang commented May 1, 2016

- What I did

This fix tries to address issues raised in #20936 and #22443 where docker pull or docker push fails because of the concurrent connection failing.
Currently, the number of maximum concurrent connections is controlled by maxDownloadConcurrency and maxUploadConcurrency which are set to 3 and 5 respectively. Therefore, in situations where network connections don't support multiple downloads/uploads, failures may encounter for docker push or docker pull.

- How I did it

This fix changes maxDownloadConcurrency and maxUploadConcurrency to adjustable by passing --max-concurrent-uploads and --max-concurrent-downloads to docker daemon command.

The documentation related to docker daemon has been updated.

- How to verify it

Additional test case have been added to cover the changes in this fix.

- Description for the changelog

Add --max--concurrent-uploads and --max--concurrent-downloads to docker daemon command so that docker pull and docker push could control the max number of concurrent connections during uploads or downloads.

- A picture of a cute animal (not mandatory but encouraged)

This fix fixes #20936. This fix fixes #22443.

Signed-off-by: Yong Tang yong.tang.github@outlook.com

@thaJeztah
Copy link
Member

Thanks!

ping @aaronlehmann wdyt?

@aaronlehmann
Copy link
Contributor

Thanks for working on this.

I wasn't sure whether this should be a daemon-level flag or a flag that can be passed to the client and transmitted through the API. Now that I think about it some more, I think a client flag would be very unfriendly, because it would have to be specified on every pull. So I think the approach here makes sense.

I'd be interested to hear opinions on this, though.

@@ -18,6 +18,11 @@ import (
)

const (
defaultMaxDownloadConcurrency = 5
defaultMaxUploadConcurrency = 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that this reverses the old defaults. The old code was:

    // maxDownloadConcurrency is the maximum number of downloads that       
    // may take place at a time for each pull.      
    maxDownloadConcurrency = 3      
    // maxUploadConcurrency is the maximum number of uploads that       
    // may take place at a time for each push.      
    maxUploadConcurrency = 5

I was a little surprised to see that there are more simultaneous uploads allowed than downloads, but I think I remember why it's like this. Registries often have high latencies to a storage backend, such as S3. At the end of a layer upload, there are multiple steps that happen to commit that upload, and because of the latency, this can take several seconds. If a push is uploading many small layers, it's faster overall to upload more at the same time, so less time is wasted in between uploads waiting for the registry to do these commits.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aaronlehmann that was a typo I must have been confused about which one is which when I was working on it.

@LK4D4
Copy link
Contributor

LK4D4 commented May 2, 2016

I'm okay with flags. However now we need validation and probably a way to specify "unlimited".

@MHBauer
Copy link
Contributor

MHBauer commented May 2, 2016

@aaronlehmann There is a client-side config file that could be used for this flag in the client.

I like 'max' something as the flag. That is the word I would first look for.

@yongtang yongtang force-pushed the 20936-22443-concurrent-connection branch 4 times, most recently from 194f9ae to 7a18b4e Compare May 3, 2016 02:34
@yongtang
Copy link
Member Author

yongtang commented May 3, 2016

Thanks @LK4D4 I just updated the validation to the added flags. Please let me know if there are any issues.

@aaronlehmann
Copy link
Contributor

Thanks @yongtang, this looks good.

To address @LK4D4's suggestion of allowing unlimited concurrency, could we make 0 mean unlimited?

As for the flag names, maybe -max-downloads and -max-uploads?

@thaJeztah
Copy link
Member

Yes, was also thinking along the lines of --max-downloads, possibly --max-concurrent-downloads, but that's quite long again.

@yongtang yongtang force-pushed the 20936-22443-concurrent-connection branch from 7a18b4e to b9bd316 Compare May 4, 2016 02:18
@yongtang
Copy link
Member Author

yongtang commented May 4, 2016

Thanks @LK4D4 @aaronlehmann @thaJeztah I just updated the pull request to change the names and make 0 as unlimited. Please let me know if there are any issues.

@yongtang yongtang force-pushed the 20936-22443-concurrent-connection branch from b9bd316 to 811ea10 Compare May 4, 2016 13:57
@aaronlehmann
Copy link
Contributor

LGTM

@thaJeztah
Copy link
Member

hm, before it's merged; should this setting be "reloadable"? https://docs.docker.com/engine/reference/commandline/daemon/#configuration-reloading, so that it can be re-configured without restarting the daemon?

@aaronlehmann
Copy link
Contributor

@thaJeztah: It already is; see the changes to the Reload function. I requested this during the review.

@aaronlehmann
Copy link
Contributor

Looks like this doc needs to be updated though - is that what you mean?

@thaJeztah
Copy link
Member

Oh! Missed that that was implemented now, didn't look at the code. But yes, it should be mentioned in the docs, below this header https://github.com/docker/docker/blob/master/docs/reference/commandline/dockerd.md#configuration-reloading

@yongtang yongtang force-pushed the 20936-22443-concurrent-connection branch from 811ea10 to 720595a Compare May 4, 2016 17:24
@yongtang
Copy link
Member Author

yongtang commented May 4, 2016

Thanks @aaronlehmann @thaJeztah I just updated the docs. Please let me know if there are any other issues.

@thaJeztah
Copy link
Member

@LK4D4 I think we can wait one day so that @yongtang can add the man page (the "primary" documentation is complete then for this feature)

@thaJeztah
Copy link
Member

Haha, so no day waiting is needed. LGTM

@icecrime
Copy link
Contributor

Sorry but I really dislike the names --max-uploads and --max-downloads, it feels like I'm going to have to pay after the first n images downloaded 😕

Explicit is better than short, can we please rename to --max-concurrent-downloads and --max-concurrent-uploads? Thanks, and sorry for being late to the party.

This fix tries to address issues raised in moby#20936 and moby#22443
where `docker pull` or `docker push` fails because of the
concurrent connection failing.
Currently, the number of maximum concurrent connections is
controlled by `maxDownloadConcurrency` and `maxUploadConcurrency`
which are hardcoded to 3 and 5 respectively. Therefore, in
situations where network connections don't support multiple
downloads/uploads, failures may encounter for `docker push`
or `docker pull`.

This fix tries changes `maxDownloadConcurrency` and
`maxUploadConcurrency` to adjustable by passing
`--max-concurrent-uploads` and `--max-concurrent-downloads` to
`docker daemon` command.

The documentation related to docker daemon has been updated.

Additional test case have been added to cover the changes in this fix.

This fix fixes moby#20936. This fix fixes moby#22443.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@yongtang yongtang force-pushed the 20936-22443-concurrent-connection branch from 113b3af to 7368e41 Compare May 12, 2016 02:47
@yongtang
Copy link
Member Author

Thanks @icecrime just updated the PR. Please let me know if there are any other issues.

@aaronlehmann
Copy link
Contributor

re-LGTM

@thaJeztah
Copy link
Member

LGTM (--max-concurrent-downloads was my second choice, so 👍 )

@icecrime
Copy link
Contributor

@yongtang Thanks a lot for the rapid update!
@aaronlehmann @thaJeztah Thanks a lot for the rapid re-review!

@icecrime icecrime merged commit e911757 into moby:master May 12, 2016
@yongtang yongtang deleted the 20936-22443-concurrent-connection branch May 12, 2016 15:54
@thaJeztah
Copy link
Member

ping @albers @sdurrheimer think this needs changes to the completion scripts. Sorry forgot to ping earlier ❤️

@albers
Copy link
Member

albers commented May 12, 2016

I'll add it to bash completion. Thanks for the ping.

yongtang added a commit to yongtang/docker that referenced this pull request May 26, 2016
This fix tries to address a separate issue raised during the
review of another PR moby#22445. The issue was raised because currently,
daemon reload will skip the action if the field (e.g., `debug`,
`labels`, etc) is not specified.

This potentially could cause some confusion:
1. Users will need to explicitly set the field if they want to unset
and they cannot assume `default` value any more
2. Users have to check the previous state of the daemon in order to
figure out the expected behavior of a reload, instead of relying on
the config file they intend to reload. Without knowing the previous
state of the daemon the behavior will be unpredictable.

In this fix, we always unset the value if not specified so that
users know what to expect based on the config file to be loaded,
instead of the previous state of the daemon (before reload).

Additional test has been added to cover the changes in this fix.

This fix is related to moby#22445.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants