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

docs: Document thread starvation scenario workaround. #11142

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/devsite-help/client-lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ builder.Services
.AddExampleClient();
```

#### Dependency injection in high-load-at-startup environments.

If your application uses Application Default Credentials while running in a Google runtime (Compute Engine,
GKE, Cloud Functions, etc.) and you expect high request load on application startup you may run into a known
issue that leads to thread starvation and high response latency. We are looking into a permanent fix,
but in the meantime you can use the following workaround: make certain you request Application
Default Credentials **during** startup configuration (you don't have to use them). For example:

```csharp
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddRazorPages()
.AddExampleClient();
// Workaround for possible thread starvation scenario.
GoogleCredential.GetApplicationDefaultCredential();
```

Note that on runtimes where high request loads lead to scaling up, the newly spawned environments are likely to
have high request load on startup which leads to this issue manifesting.

Please see https://github.com/googleapis/google-cloud-dotnet/issues/11092 for fresh updates.

## Clean-up

When a single client is used for an entire application lifecycle, there is no need to clean anything up.
Expand Down