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

Added qps and burst to server's client #956

Merged
merged 1 commit into from
Nov 9, 2018

Conversation

ffd2subroutine
Copy link
Contributor

Signed-off-by: Darko Radisic [email protected]

Fixes #109

@rosskukulinski
Copy link
Contributor

Hi @ffd2subroutine - thanks for the PR! I noticed you marked this as work-in-progress. Is there anything in particular you're still planning to do or is this ready for review from someone from the Ark team?

@ffd2subroutine
Copy link
Contributor Author

Hi @rosskukulinski, yeah it's ready for review, maybe @ncdc can take a look at this one.

@nrb
Copy link
Contributor

nrb commented Oct 18, 2018

Thanks for the PR @ffd2subroutine. I'll give this a read and test and get back to you.

@nrb nrb changed the title [wip] Added qps and burst to server's client Added qps and burst to server's client Oct 18, 2018
@nrb nrb requested review from skriss and nrb October 18, 2018 20:15
Copy link
Contributor

@nrb nrb left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me, based on the issue and other examples of overriding the same parameters I've found in other projects.

@ncdc and @skriss do we want to keep the defaults the same, or up them at all?

@rosskukulinski rosskukulinski added this to the v0.10.0 milestone Oct 18, 2018
@ncdc
Copy link
Contributor

ncdc commented Oct 19, 2018

I think upping the defaults makes sense. I just looked at Kubernetes 1.11, and it looks like the controller-manager's defaults are qps=20, burst=30. I like those values - what do you all think?

@skriss
Copy link
Contributor

skriss commented Oct 19, 2018

@ncdc going with controller-manager's defaults sounds reasonable to me!

nrb
nrb previously requested changes Oct 19, 2018
Copy link
Contributor

@nrb nrb left a comment

Choose a reason for hiding this comment

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

Thanks for updating that @ffd2subroutine!

2 more things (I missed this the first time): can you squash the commits into 1, as well as add a sign off line? git commit --amend --sign-off will add the signed off line for you.

@ncdc
Copy link
Contributor

ncdc commented Oct 19, 2018

@skriss @nrb should we try wordsmithing the flag help text a little bit?

@nrb
Copy link
Contributor

nrb commented Oct 19, 2018

@ncdc Probably worth doing, yeah.

@@ -153,6 +161,8 @@ func NewCommand() *cobra.Command {
command.Flags().StringSliceVar(&config.restoreResourcePriorities, "restore-resource-priorities", config.restoreResourcePriorities, "desired order of resource restores; any resource not in the list will be restored alphabetically after the prioritized resources")
command.Flags().StringVar(&config.defaultBackupLocation, "default-backup-storage-location", config.defaultBackupLocation, "name of the default backup storage location")
command.Flags().Var(&volumeSnapshotLocations, "default-volume-snapshot-locations", "list of unique volume providers and default volume snapshot location (provider1:location-01,provider2:location-02,...)")
command.Flags().Float32Var(&config.clientQPS, "client-qps", config.clientQPS, "server's client qps")
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably be more descriptive here. Something along the lines that this is the maximum number of requests per second the server uses when communicating with Kubernetes when backing up and restoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maximum number of requests per second the server uses when communicating with Kubernetes when backing up and restoring

Would that be okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm!

Copy link
Contributor

Choose a reason for hiding this comment

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

Wanted to jot this down before I forget - I'm not sure if "maximum" is the best word here, since it's possible to burst above the qps. It's more like the average sustained requests rate.

Copy link
Contributor

Choose a reason for hiding this comment

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

"quota" seems like one of the right words here. Something like "standard quota of requests per second to Kubernetes"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, let me know the final wording for qps and burst param descriptions!

@@ -153,6 +161,8 @@ func NewCommand() *cobra.Command {
command.Flags().StringSliceVar(&config.restoreResourcePriorities, "restore-resource-priorities", config.restoreResourcePriorities, "desired order of resource restores; any resource not in the list will be restored alphabetically after the prioritized resources")
command.Flags().StringVar(&config.defaultBackupLocation, "default-backup-storage-location", config.defaultBackupLocation, "name of the default backup storage location")
command.Flags().Var(&volumeSnapshotLocations, "default-volume-snapshot-locations", "list of unique volume providers and default volume snapshot location (provider1:location-01,provider2:location-02,...)")
command.Flags().Float32Var(&config.clientQPS, "client-qps", config.clientQPS, "server's client qps")
command.Flags().IntVar(&config.clientBurst, "client-burst", config.clientBurst, "server's client burst")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure the best way to write this clearly. It's a higher-than-average number of requests (more than QPS) that are allowed in a small window of time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that the QPS is the normal number of requests per second, the burst is the ability to exceed the QPS for a short period of time. Here's how it works:

There is a "bucket" that has a fixed capacity. This capacity is the "burst" value. Let's use an example of 30. The bucket is initially filled to capacity, so it has 30 tokens. You can pull tokens out as fast as possible, which means you can initially do 30 requests. The bucket also has a rate at which it is filled - this is the QPS. Here let's use an example of 20. This means a new token is added to the bucket approximately every 1/20 of a second. If you are constantly making requests, the steady rate will be 20/second. If you pause for long enough, the bucket will fill to capacity == burst == 30 in this example.

I'm still thinking about wording.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and thanks for the explanation!

Copy link
Contributor

Choose a reason for hiding this comment

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

It is a maximum value, but it's not a sustained rate.

For example, if the burst is 100 and the qps is 5, and you have a steady stream of requests you need to make, what happens is initially you can make 100 requests as fast as you're able to do so, and all additional requests will average 5 per second. The only way you get back to 100 (the burst) is if there is a pause in requests for (burst / qps) seconds to allow the bucket to refill (100/5 = 20 seconds).

Copy link
Contributor

@Bradamant3 Bradamant3 Oct 30, 2018

Choose a reason for hiding this comment

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

what kind of usable string length requirements do we have here? (pondering further ...)

Copy link
Contributor

Choose a reason for hiding this comment

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

"temporary maximum ..." ? "emergency maximum ..." ?

or if a longer string would work:

"one-time maximum number of requests to exceed QPS before pausing to refresh burst"

Copy link
Contributor

Choose a reason for hiding this comment

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

"short-term maximum number of requests to exceed QPS before pause to refresh burst"

I think this one or the other longer alternative are not too bad (actually useful) if we can accommodate longer string

Copy link
Contributor

Choose a reason for hiding this comment

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

I think "short-term" or "temporary" is probably good

Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Hi @ffd2subroutine - will you be able to get this updated so we can include it in the upcoming release? Thanks!

@@ -446,6 +458,8 @@ func (s *server) validateBackupStorageLocations() error {
// - Limit ranges go before pods or controllers so pods can use them.
// - Pods go before controllers so they can be explicitly restored and potentially
// have restic restores run before controllers adopt the pods.
// - Custom Resource Definitions come before Custom Resource so that they can be
Copy link
Contributor

Choose a reason for hiding this comment

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

This has already made it into master so can be removed from this PR

Copy link
Contributor Author

@ffd2subroutine ffd2subroutine Oct 30, 2018

Choose a reason for hiding this comment

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

sorry I was squashing commits for the first time and it squashed everything in between, will remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -456,6 +470,7 @@ var defaultRestorePriorities = []string{
"limitranges",
"pods",
"replicaset",
"customresourcedefinitions",
Copy link
Contributor

Choose a reason for hiding this comment

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

This has already made it into master so can be removed from this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@skriss
Copy link
Contributor

skriss commented Nov 8, 2018

@ncdc @Bradamant3 would like to get this into v0.10, so we just need to finalize help text. WDYT about these:

client-burst: maximum number of requests by the server to the Kubernetes API in a short period of time
client-qps: maximum number of requests per second by the server to the Kubernetes API once the burst limit has been reached

@ncdc
Copy link
Contributor

ncdc commented Nov 8, 2018

Sounds good enough for now!

@skriss
Copy link
Contributor

skriss commented Nov 8, 2018

@ffd2subroutine if you can update the help text to what I proposed just above, we should be good to merge - thanks!

@ncdc
Copy link
Contributor

ncdc commented Nov 9, 2018

@ffd2subroutine thanks - would you mind rewording the commit message so it doesn't have [wip] in it any more?

Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Approved pending removal of [wip] from commit message :)

@@ -197,6 +207,8 @@ func newServer(namespace, baseName string, config serverConfig, logger *logrus.L
if err != nil {
return nil, err
}
clientConfig.QPS = config.clientQPS
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know why I didn't think of this sooner - should we validate these are positive numbers?

Copy link
Contributor Author

@ffd2subroutine ffd2subroutine Nov 9, 2018

Choose a reason for hiding this comment

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

yeah makes sense, I also forgot

	if config.clientQPS <= 0 {
		return errors.New("client-qps can be only a positive number")
	}

Something like this? Maybe some better wording, not a native english speaker:)

Copy link
Contributor

Choose a reason for hiding this comment

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

That's good, or client-qps must be positive

@nrb nrb dismissed their stale review November 9, 2018 16:37

Changes addressed, but haven't reviewed latest code.

@skriss
Copy link
Contributor

skriss commented Nov 9, 2018

LGTM, thanks @ffd2subroutine!

@skriss skriss merged commit 2781e4e into vmware-tanzu:master Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants