Memory optimization

General notes

Turnkey memory optimization that are built in and don't need any configuration;

  • Large blobs in a model is held in a shared location for all clients.
  • Pruning (deallocation) of unused data structures periodically, usually every few minutes, even in views and in the EcoSpaces of active users.
  • Removing viewmodels that have not been used for a few minutes.
  • Removal of subscriptions and change publishers within EcoSpaces every few minutes.

Using the ServerInfo page you can temporarily tweak times for pruning stale apps and the interval at when the server does pruning. These settings are available to make it easier for you to tweak other settings without having to wait very long periods of time to see the effect.

.Net optimization settings for .Net Framework <4.8.1, not .Net core on IIS

When a .Net application doesn't use objects any more, they are garbage collected.The Garbage Collector (GC) can do it's job in many ways.

By default an MDriven Server uses the "Server" GC mode with the "Interactive" setting. This is to make the garbage collector to run in the background and in a way that should minimize user "hick-ups", i.e. short delays for the user.

There's always a balance between user experience, memory use and CPU use to consider.

  • Tuning GC for high-density Web hosting: GC can impact a site’s memory consumption, but it can be tuned to enable better performance. You can tune or configure GC for better CPU performance (slow down frequency of collections) or lower memory consumption (that is, more frequent collections to free up memory sooner).
<performanceScenario value="HighDensityWebHosting"/>
  • Tuning only when memory usage on server low memory conditions, use gcTrimCommitOnLowMemory like this;
<gcTrimCommitOnLowMemory enabled="true"/>

Both of these setting you add the settings to the runtime section of the aspnet.config file in the C:\Windows\Microsoft.NET\Framework64\v4.0.30319 folder in order to achieve smaller memory consumption (working set) per site.

Aspnet.config file example.png

In an installation with more than one TK or MDS instance running on a Windows machine, we recommend both settings to make them run much better together, like this;

See also: Turnkey Client Timeout

More reading;

https://learn.microsoft.com/en-us/archive/msdn-magazine/2012/april/clr-an-overview-of-performance-improvements-in-net-4-5

https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/optimization-for-shared-web-hosting

This page was edited 83 days ago on 02/10/2024. What links here