NHibernate - Memcached 性能不佳

发布于 2024-11-02 03:00:11 字数 964 浏览 0 评论 0原文

我安装了 Membase 并创建了一个新的 memcached 存储桶。在设置中,为了简单起见,我选择设置端口 ID 为 1111 的专用端口。

在我的 web.config 中,我有这个:

<configSections>
  <section name="memcache" type="NHibernate.Caches.MemCache.MemCacheSectionHandler, NHibernate.Caches.MemCache" requirePermission="false" />
  ...
</configSections>

<memcache>
  <memcached host="127.0.0.1" port="1111" />
</memcache>

在我的 NHibernate 配置部分:

<property name="cache.use_query_cache" >true</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.provider_class">NHibernate.Caches.MemCache.MemCacheProvider, NHibernate.Caches.MemCache</property>

在每个 NHibernate 类映射中,我在类标记之后的右上角都有这个:

<cache usage="nonstrict-read-write" />

当我运行这个时,我的查询比 if 慢一个数量级我正在使用 Syscache。有什么看起来不对劲的地方吗?我对设置这样的东西相当陌生。

预先感谢您的任何帮助。

I installed Membase and created a new memcached bucket. In the settings, I chose to setup a dedicated port with port ID of 1111 for simplicity sake.

In my web.config I have this:

<configSections>
  <section name="memcache" type="NHibernate.Caches.MemCache.MemCacheSectionHandler, NHibernate.Caches.MemCache" requirePermission="false" />
  ...
</configSections>

<memcache>
  <memcached host="127.0.0.1" port="1111" />
</memcache>

In my NHibernate config section:

<property name="cache.use_query_cache" >true</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.provider_class">NHibernate.Caches.MemCache.MemCacheProvider, NHibernate.Caches.MemCache</property>

In each of my NHibernate class mappings, I have this at the top right after the class tag:

<cache usage="nonstrict-read-write" />

When I run this, my queries are an order of magnitude slower than if I was using Syscache. Is there anything that looks wrong? I am fairly new to setting something like this up.

Thanks in advance for any assistance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疯了 2024-11-09 03:00:11

您的配置似乎没有任何明显的问题。 Syscache 使用 ASP.NET 缓存提供程序,并且您的应用程序和缓存之间没有网络通信,但理论上它仍然应该只比本地主机上运行的 memcached 快一点(假设您有足够的内存来避免交换)。

您可能想尝试使用分析器运行您的应用程序,以查看时间实际花在哪里。此外,您还应该确保 memcached 实际上用于返回缓存的查询,并且不会发出 sql 查询 - 记录 sql 并期望仅在第一次执行查询时看到它。

我正在将 membasememcached 存储桶enyim memcached 客户端,配置与您类似我对这次的表现非常满意。 membase 还提供了一个很好的管理控制台,您可以在其中查看有关缓存使用情况的各种有用的统计信息。

另外,与您的问题无关,但请确保您在启用查询缓存之前了解查询缓存的工作原理。请参阅两个 帖子 来自阿延德。

You don't seem to have any obvious problems in your configuration. Syscache is using the ASP.NET cache provider and there is no network communication between your app and the cache, but still it should in theory only be a little faster than memcached running on localhost (this assuming you have enough memory to avoid swapping ).

You might want to try to run your app with a profiler to see where the time is actually spent. Also you should make sure that memcached is actually used to returned the cached queries and no sql query is issued - log the sql and expect to see it only the first time the query is executed.

I'm using membase with a memcached bucket and the enyim memcached client, with a configuration similar to yours and i'm very pleased with the performance. The membase also provides a nice administration console where you can see various useful statistics about cache usage.

Also, not related to your question but, make sure you understand how query caching works before enableing it. See this two posts from ayende.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文