c# - Garbage Collection Modes : If 2 apps exist on a server, "Server Mode"难道是劫以还债?

标签 c# garbage-collection clr load-balancing

两人组(如有必要,我可以分开问题来奖励单独的正确答案):

我们所处的情况可能适合在服务器模式下运行:我们有 2 个企业级应用程序在同一个服务器场上运行。如果我将两个应用程序的应用程序配置收集模式都置于“服务器模式”,我是否会冒着每次其他 GC 都会伤害一个应用程序的风险?

网络负载均衡器是否会将流量从 GC 中间的机器转移开(再次在服务器模式下)?

编辑 我把这个问题的负载平衡部分分解到这里:Is the network load balancer of a web farm affected by GC strain?

最佳答案

如果您担心两个企业应用会影响彼此的性能,您应该考虑将它们移到两个单独的虚拟机中。

GC 经过优化并在它自己的线程中运行。它被设计为对当前应用程序不可见。所以在多处理器企业服务器上,一个单独的进程根本不会被破坏。

从另一方面来看,服务器仍然从 GC 获得一些负载。如果您觉得 GC 以某种方式减慢了您的应用程序,您可能会执行一些内存和 CPU 分析以查看问题出在哪里。您可能会找到优化代码和使用更少资源的方法。

来自 J.Richter“通过 C# v3 的 CLR”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.

关于c# - Garbage Collection Modes : If 2 apps exist on a server, "Server Mode"难道是劫以还债?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6931200/

相关文章:

java - 同时从多个线程调用 weakReference.get() 方法是否安全?

c# - .NET 运行时如何移动内存?

.net - 单个 .NET 程序集针对两个不同的 CLR?

asp.net - IIS7.5 中 x64 进程的内存限制

c# - 了解非 bool 参数之间的按位比较

c# - Controller 返回FileStreamResult时如何清除\清除模型状态错误?

java - Java中的Finalize方法[垃圾回收]

.net - 是否在运行时评估了 assembly.dll.config 中的绑定(bind)重定向?

c# - 获取网络下载和上传速度

c# - 无法使用 C# 连接到启用 OnVif 的相机