How does the difference between the Server GC and Workstation GC modes affect a .NET application's throughput and latency characteristics?
Short answer
Workstation GC (the default for client apps) optimizes for LOW LATENCY, running collections on a single thread with minimal pause impact on a UI thread; Server GC (typical for ASP.NET Core web servers) optimizes for HIGH THROUGHPUT by using MULTIPLE dedicated GC threads (one per…
Advertisement
AModel answer
Workstation GC (the default for client apps) optimizes for LOW LATENCY, running collections on a single thread with minimal pause impact on a UI thread; Server GC (typical for ASP.NET Core web servers) optimizes for HIGH THROUGHPUT by using MULTIPLE dedicated GC threads (one per CPU core) and separate heaps, trading slightly higher pause times for much better overall performance under heavy concurrent load.
// runtimeconfig.json or .csproj setting
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
// ASP.NET Core apps typically benefit from Server GC due to high, concurrent allocation ratesReal-world example
Choosing Server GC for a high-throughput web API versus Workstation GC (with concurrent GC enabled) for a responsive desktop application.
Likely follow-ups
- Why might Server GC actually be a poor choice for a container with a very LOW CPU core limit?
Related topics