问题描述
你好,
我用C#编写了一个高性能的Web应用程序,它完全依赖于
静态哈希表(使用同步)和类。在现实世界的压力下,这个
应用程序每秒处理每个CPU 5个请求。
我已经从单核/单进程中解决了,对于双核/单一进程到双核/双进程,并且因为我怀疑每秒每秒请求的数量
CPU不会增加它仍然是每个CPU 5个。
我读取IIS线程表明,每秒10-12个请求可以从非静态类中获得
基于应用程序如果这个假设是正确的,那么你对我如何能够每秒增加
请求的数量有什么建议吗?
TIA
Hello,
I''ve written a high performance web app with C# and it completely relies on
static hash tables (using sync) and classes. Under real world stress this
app is handling 5 get requests per CPU per second.
I''ve gone from a single-core/single-proc, to a dual-core/single-proc to a
dual-core/dual-proc and as I suspected the number of requests per second per
CPU does not increase it remains at 5 per CPU.
My reading of IIS threading suggests that 10-12 per requests per second can
be expected from a non-static class based app. If this assumption is
correct, do you have any suggestions on how I might be able to increase the
number of requests per second?
TIA
推荐答案
如果你使用的是System.Collections.Hashtable对象并且大部分都在阅读它们,那么你可以利用Hashtable的特性对于多个读者或只有一个作者来说,它是线程安全的
。而不是使用同步,
使用ReaderWrtiterLock,这将为您提供更好的并发性。
If you are using System.Collections.Hashtable objects and mostly reading
them, you can make use of the characteristic of the Hashtable of being
thread-safe for multiple readers or only one writer. Instead of using sync,
use a ReaderWrtiterLock, which will give you better concurrency.
这篇关于静态HashTables和类对CPU有什么影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!