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

Limit Secret loading parallelism #15492

Merged
merged 2 commits into from
Sep 29, 2020

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Sep 28, 2020

Fixes: #13011

@pakrym pakrym requested a review from heaths September 28, 2020 18:18
{
private const int ParallelismLevel = 32;
private readonly SecretClient _client;
private readonly SemaphoreSlim _semaphore;
Copy link
Member

Choose a reason for hiding this comment

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

Thought: could just use a ConcurrentQueue and avoid the housekeeping here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain, please? I don't know a way to use CQ to limit parallelism.

Copy link
Member

Choose a reason for hiding this comment

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

As noted below, you have a small pool of threads pull work off a queue. I've written/helped write several pipelines that use that approach (mostly setup engines / chainers). The number of threads in the pool is limited, so worker queues are bounded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. I tried to avoid having to manage my own thread pool, for now, especially considering that async completions would be executed on the real thread pool anyway.

{
internal class ParallelSecretLoader: IDisposable
{
private const int ParallelismLevel = 32;
Copy link
Member

Choose a reason for hiding this comment

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

Is there any practical chance more than one instance is created? For example, could middleware in the app pipeline fetch it's own? Is that enough of a concern to basically design this class to be static and reentrant? You could, for example, keep queueing secrets to fetch and have a pool of worker limited worker threads dequeueing from it (a tactic I've used in the past on a couple different projects).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More than one instance of this class? I expect it's possible but not too common as you can add multiple KeyVaults to a configuration builder.

I'm a bit reluctant to create a global chokepoint though as those have their own set of scaling issues.

@pakrym pakrym merged commit 3cc6d3e into Azure:master Sep 29, 2020
@pakrym pakrym deleted the pakrym/limit-secret-parallelism branch September 29, 2020 19:47
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.

Limit parallelism in KeyVault configuration provider
2 participants