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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike: Configurable concurrency #52

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Jan 10, 2024

馃毀 Spike - early version for feedback

Resolves #12

@alpe alpe force-pushed the 12_configurable_concurrency branch from ea7eb45 to 4b8f8ca Compare January 10, 2024 15:20
concurrencyMtx sync.RWMutex
// concurrency is the max number of in progress items.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for having both concurrency and concurrencyPerReplica?

Copy link
Contributor

Choose a reason for hiding this comment

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

concurrency seems store total queue size whereas concurrencyPerReplica is the per replica.

So if there are 3 replicas and concurrency per replica is 100 then concurrency would be 300.

Maybe we should rename concurrency to size OR maxConcurrentRequests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@samos123 is correct. Let's have better names. I have updated the doc already:

// // concurrency is the max number of in progress items on all replicas. Same as `number_replicas * concurrencyPerReplica`
// concurrencyPerReplica is the max number of in progress items that a single replica instance can handle.

concurrencyMtx sync.RWMutex
// concurrency is the max number of in progress items.
Copy link
Contributor

Choose a reason for hiding this comment

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

concurrency seems store total queue size whereas concurrencyPerReplica is the per replica.

So if there are 3 replicas and concurrency per replica is 100 then concurrency would be 300.

Maybe we should rename concurrency to size OR maxConcurrentRequests?

pkg/queue/queue.go Show resolved Hide resolved
return
}

replicas := q.concurrency / int(q.concurrencyPerReplica)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we get number of replicas from the system? The number of replicas fluctuates frequently and I think replicas counted this way would often not match the replicas in the actual system.

Maybe it should take a 2nd parameter: replicas int, because the deploy manager has the actual current replicas that kubernetes reports.

Copy link
Contributor Author

@alpe alpe Jan 18, 2024

Choose a reason for hiding this comment

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

Two different processes are involved that can change the max of total concurrent in flight requests. The endpoint and the deployment reconciler. Both are used in the autoscaler but are otherwise independent. The state shared was in the queue type.

By calculating the new total by deriving the (best known) replica count, each process uses the data they own.
But we can also store the number of replicas for a deployment and not do the math in the queue type. This would be a cleaner separation.

pkg/queue/queue.go Show resolved Hide resolved
// SetCurrencyPerReplica updates the concurrency value per replica for a specific deployment.
// If the provided value is 0, it sets the concurrency value to the default value.
// This function updates the concurrency value directly on the queue associated with the deployment.
func (r *Manager) SetCurrencyPerReplica(deploymentName string, newPerReplica uint32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

typo? should this be SetConcurrencyPerReplica instead of SetCurrencyPerReplica?

m.queues[deploymentName] = q
go q.Start()
}
return q
}

func (r *Manager) GetCurrencyPerReplica(deployment string) uint32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

typo? should this be GetConcurrencyPerReplica instead of GetCurrencyPerReplica?

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.

Configurable concurrency per replica setting
3 participants