Skip to content

Commit

Permalink
docs: Document thread starvation scenario workaround.
Browse files Browse the repository at this point in the history
Towards #11092
  • Loading branch information
amanda-tarafa committed Oct 4, 2023
1 parent 0eea6bd commit 269b187
Showing 1 changed file with 22 additions and 0 deletions.
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,
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();
// Workarounf 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

0 comments on commit 269b187

Please sign in to comment.