azure - 连接到新的 Azure 缓存(DataCache、DataCacheFactory 和连接池)

标签 azure azure-caching

Windows Azure Caching Document

If possible, store and reuse the same DataCacheFactory object to conserve memory and optimize performance."

有没有人看到过任何衡量其成本的指标或量化数据?

One argument is that

"MaxConnectionsToServer setting... determines the number of chennels per DataCacheFactory that are opened to the cache cluster."

因此,如果 MaxConnectionsToServer = 1 并且 DataCacheFactory 是您应用中的单例,那么您已有效地将所有请求同步到您的 Web 服务器!

但是,there is a lot指示 DataCacheFactory 应该是单例(即放入 Application_OnStart)。

这很关键,我不敢相信它不在 Microsoft 文档中。 DataCacheFactory 在 AppFabric、Azure 共享缓存和 Azure 缓存中的处理方式是否相同?我只是很难相信微软以需要单例工厂对象的方式设计缓存。这就像要求任何使用 SqlConnection 的人在其应用程序中拥有一个单例 SqlConnectionFactory 对象。

因此,考虑一个相对平均的 Web 应用程序(例如,每小时 1,000 个请求,缓存中约有 100 个对象,平均请求访问 5 个缓存对象):

  1. 默认情况下(和建议)一次应该有多少个 Factory 对象?
  2. 创建 DataCacheFactory 引用需要多长时间?
  3. 创建 DataCache 引用需要多长时间?
  4. 每个应用只能有 1 个 DataCacheFactory 对象,每个请求只能有 1 个 DataCache 引用吗?
<小时/>

编辑(正在回答):

(1/2)。让 Azure 连接池处理 Factory 对象

(3)。仍在测试...

(4)。仍在尝试弄清楚是否应该重新使用 DataCache 引用

最佳答案

怎么样,微软确实记录了最佳实践,并且确实涉及连接池!虽然不容易找到(至少对我来说)。

看来答案就是在实现较新的 Azure 缓存时不使用 DataCacheFactory 对象,而只是 access the DataCache object directly

"There are also new overloads to the DataCache constructor that make it simpler to create a cache client. In the past, it was always necessary to create a DataCacheFactory object that returns the target cache. Now it is possible to create the cache with the DataCache constructor directly. The following example creates a client to the default cache from the default section of the configuration file."

DataCache cache = new DataCache();

And to use connection pooling .

"With the latest Windows Azure SDK, connection pooling is enabled by default when you define your cache settings in the application or web configuration files. Because of this default behavior, it is important to set the size of the connection pool correctly. The connection pool size is configured with the maxConnectionsToServer attribute on the dataCacheClient element."

我希望 Microsoft 就如何正确配置 maxConnectionsToServer 提供一些指导,但这可以通过测试来确定。使用新的 Azure 缓存的自动连接池非常酷:)

关于azure - 连接到新的 Azure 缓存(DataCache、DataCacheFactory 和连接池),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15399102/

相关文章:

azure - 是否始终需要对(Azure Blob 存储)存档层进行补充?

azure - 在本例中输出 Bicep 中的数组是正确的方法吗?

azure - Azure 中的云服务运行状况不佳

azure - 从客户端获取redis azure缓存的最大内存

azure - 在 Microsoft Azure 门户中创建 SQL 数据库时,如果我的 "Region"不在列表中,该怎么办?

azure - Azure 协同缓存和 InProc 之间的交换

java - 如何通过 Java 使用 Azure 缓存服务(预览版)

asp.net - 如何注入(inject)/处理 HttpContex.Cache 的使用

azure - 增加缓存角色的MaxBufferSize

azure - 对特定受众隐藏 Azure 表中的数据