TL;DR: In containerized environments, try disabling ServerGarbageCollection and check whether there is a notable performance boost. To do so, alter your project file with the following:
<PropertyGroup>
  <ServerGarbageCollection>false</ServerGarbageCollection>
</PropertyGroup>

Most of the times, it is only after you have a working product that you start caring about performance and optimizations.

That being said, I figured out, only recently, that there are two Garbage Collection (GC) modes in ASP.NET Core.

During the investigation of some memory-leaks and sudden upwards memory bursts in our Kubernetes deployment, I came across this great article on Memory Management & GC followed by two more elaborate investigations on containerized environments: Running with Server GC – Part 0 and Running with Server GC – Part 1.

As noted in the original article, there is Workstation GC and Server GC. The latter, is enabled by default and requires > 1 CPU cores to operate whilst the former, assumes that the application is running in a desktop environment, and is optimized against it.

In addition, quoting from Running with Server GC – Part 0:

First of all, as many of you already knew, Server GC was designed with the assumption that the process using Server GC is the dominant process on the machine. By default it uses as many heaps as there are # of processors on the machine. Technologies like asp.net use Server GC by default. And this is a great choice when your asp.net process is indeed the dominant process which had often been the case for many years. But as folks start to put these processes into containers with low/lower memory limits, it doesn’t bode well if for example your container only uses 200mb of memory and happening to be running on a machine with 48 procs – it doesn’t make sense to have 48 heaps to just collect 200mb.

By now, it should be pretty obvious where I am getting to, and that’s nothing else, other than you might have been using the wrong configuration all along.

If your deployment, like in our case, is in a containerized environment with memory-constraints, it might be a good idea to investigate whether Workstation GC suits your case best.

Take notice though. There is no definite answer here, but rather you have to figure out whether CPU or memory utilization is your greatest concern.

You can start by profiling your application and switching between Workstation GC and Server GC with the property provided in the snippet above.

PS: If you have time, make sure to read the articles for more elaborate explanations.