After upgrading our demo stores to nopCommerve 4.10 we've started to experience problems with our stores. They were super slow.
After inspecting the server our demo stores are running on we found something really troubling - our demo stores were using all of our system resources. The memory and CPU usage of our system were at 100%.
Due to that situation, our SQL Server was capped at half the memory it normally uses to run with that many application connected to it. This made our demo stores extremely slow.
After further inspection, we saw that all of our stores are using 3-5 times more memory to run. In some cases, the .NET Core Host process used up to 1,3GB of memory for a single store. We have a total of 45 stores hosted on that system. Prior to the 4.10 update, the server didn't have any problems running that many sites. We had to do something about it.
After some research, we found out that disabling the Server Garbage Collector might help us in such a situation. There are two main modes of Garbage Collectors - Server and Workstation. The difference between them is that Workstation GC is designed for lightweight application on single-core systems and minimizes the time spent in GC while Server GC is optimized for application throughput in favour of longer GC pauses and higher memory consumption.
The GC in Workstation GC happens more frequently but with shorter pauses in the application threads which is ideal for UI applications that have a high refresh rate (such as games or console applications for example). The Server GC is optimized for a server application that would usually run on multi-core systems and can support many users. The Server GC uses more memory and the amount of memory depends on the number of cores on your system - more cores means more memory usage. This is the thing that got our attention.
Since our demo stores are running all our products we tried to build our products using the Workstation GC. That didn't improve anything. All of our sites were using around 1GB of memory. Then we tried building nopCommerce using the Workstation GC. We downloaded the Source version of nopCommerce 4.10 and added the following code to the Nop.Web.csproj file :
<PropertyGroup>
<ServerGarbageCollection>false</ServerGarbageCollection>
</PropertyGroup>
After that, we built and published the Nop.Web project and replaced the nopCommerce files of all our demo sites with the newly published ones.
Immediately, we saw a massive improvement. All of the sites are now using around 300MB of memory. That is 3-5 times lower than before! Our server is no longer out of memory and our sites are as fast as before the update.
I even ran a test on my local machine. The processes below are of the same site - clean nopCommerce and newly installed database. The only difference is the mode of the GC - first is using Workstation, the second Server GC.
You can see for yourself that the allocated memory is alot lower.
On paper, using the Workstation GC should result in less memory usage but should also lower the performance of the site. In practice, we do not see any degradation of the performance of our demo stores, but we saw a great decrease in the memory usage. I don't think this would apply to everyone, though, since our sites don't often get more than 100 people browsing them at a time due to the fact that they are just for showcase and not real stores.
I think this might be useful for people that faced the same problem as us, and don't have a lot of options, though.
Hope that information was useful to anyone!
Regards,
Anton