AppFabric性能问题 [英] AppFabric Performance Issues

查看:87
本文介绍了AppFabric性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

 我们正在试验AppFabric Cache中的性能问题。情况是:

 We are experimenting performance problems in our AppFabric Cache. The situation is:

有时候我们的应用程序非常慢而其他时间很快。

Sometimes our application is very slow and other times is fast.

这是我们的代码

----------------------------------------------- -------------------------------------------------- ---------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------

 

if (m_cache ==
< span style ="color:#0000ff; font-size:x-small"> null )===此变量是静态的,这意味着我们只加载一次

{

{

m_cache =

m_cache =

CacheUti l 。GetCache();

CacheUtil.GetCache();

 }

sessionId =(

sessionId = (

string )m_cache.Get(ipSessionIdKey);

-------------------------------------- -------------------------------------------------- -------------------------------------------------- ----

----------------------------------------------------------------------------------------------------------------------------------------------

要执行这些代码行,我们的应用程序将在30毫秒到500毫秒之间消耗。

To execute these lines of code our application is expending between 30 miliseconds and 500 miliseconds.

我们每隔20发送一个请求几秒钟,我们没有太多的流量。

We are sending a request every 20 seconds and we don't have much traffic.

 请,有人可以帮助我们吗?我们需要更改配置吗?如果我们迁移到MemCache会更好

 Please, could somebody help us? Do we need to change the configuration? Is better if we migrate to MemCache

 问候和感谢

 Regards and thanks

 

推荐答案

最重要的是每个进程创建一个DataCacheFactory实例。这是非常昂贵的创建。 没有必要将DataCache实例保留在静态字段上,但你可以。

The most important is to create 1 instance of DataCacheFactory per process. That is very expencive to create. It is not necessary to keep the DataCache instance on static field, but you could.

还要记住在创建DataCacheFactory时使用锁定确保只创建了一个实例。

Also keep in mind to use locking in the creation of the DataCacheFactory to make sure only 1 instance is created.

类似于:

private static DataCacheFactory _cacheFactory;
static readonly object _locker = new object();
if (_cacheFactory == null)
{
if (Monitor.TryEnter(_locker, 20000))
{
try
{
if (_cacheFactory == null)
{


				_cacheFactory = new DataCacheFactory(..);
			}


		}
finally
{
Monitor.Exit(_locker);
}
}
}


We have plenty of requests per second and it takes about 1-2 ms per request to get our object of 8KB.




如果可以,请发布CacheUtil.GetCache()的代码。

If this is ok, then please post the code for the CacheUtil.GetCache().


You could also analyze code performance and see what is on the hot path/slow in code. Maybe its something else?


这篇关于AppFabric性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆