A 2-parter (if necessary I can seperate questions to award seperate right answers):
We're in a situation where running in server mode is likely appropriate: We have 2 enterprise level apps running on the same farm. If I put the app config Collection Modes of both apps in "Server Mode" am I risking hurting one app every time the other GC's?
开发者_StackOverflow中文版Will the Network Load Balancer shift traffic away from a machine in the middle of GC (again in server mode)?
EDIT I broke the Load Balancing part of this question over to here: Is the network load balancer of a web farm affected by GC strain?
If you are concerned about two enterprise app influencing performance of each other you shall consider moving them into two separate VMs.
GC is optimised and running in it's own thread(s). It is designed to be invisible for the current application. So on a multiprocessor enterprise server, a separate process shall not be damaged at all.
From the other point, server is still getting some load from GC. If you feel that GC somehow slows down your applications, you might probably perform some memory and CPU profiling to see where is a problem. You may find a way to optimize code and use less resources.
From J.Richter "CLR via C# v3" p.585
This mode fine-tunes the garbage collector for server-side applications. The garbage collector assumes that no other applications (client or server) are running on the machine and it assumes that all the CPUs on the machine are available to do a garbage collection. This GC mode causes the managed heap to be split into several sections, one per CPU. When a garbage collection is initiated, the garbage collector has one thread per CPU; each thread collects its own section in parallel with the other threads. Parallel collections work well for server applications in which the worker threads tend to exhibit uniform behavior. This feature requires the application to be running on a computer with multiple CPUs so that the threads can truly be working simultaneously to attain a performance improvement.
From MSDN (emphasis added)
Workstation is the default GC mode and the only one available on single-processor computers. Workstation GC is hosted in console and Windows Forms applications. It performs full (generation 2) collections concurrently with the running program, thereby minimizing latency. This mode is useful for client applications, where perceived performance is usually more important than raw throughput.
The server GC is available only on multiprocessor computers. It creates a separate managed heap and thread for each processor and performs collections in parallel. During collection, all managed threads are paused (threads running native code are paused only when the native call returns). In this way, the server GC mode maximizes throughput (the number of requests per second) and improves performance as the number of processors increases. Computers with four or more processors offer enhanced performance. All managed code applications using Lync Server Application API should use the server GC.
In Server Mode, GC runs periodically on all processors in parallel. This could rob other applications of CPU time during collection.
So Server Mode might improve the performance of an application, but it might degrade the performance of other applications running on the same server. It's all very speculative - I think you'll have to do some benchmarking to test the responsiveness and throughput of your applications to know for sure.
I have seen runaway memory allocation due to a lazy GC affect seemingly unrelated processes before. However, it does not appear that server mode does that (hog system memory to decrease collection frequency) so you should be fine.
精彩评论