问题
I'm currently evaluating Windows Server AppFabric as a distributed cache solution. If we implement AppFabric, we'd have something like 3 or 4 different web applications using it for caching. I've seen that AppFabric provides the ability to created named caches. I'm wondering if it's possible to set a max size on on a named cache? It looks like you can set a max. memory size for a cache cluster host but I haven't seen anything to indicate that this can be done on a per cache basis.
The reason I'm interested in setting a max. size on a per cache basis is my thought is we'd create one named cache per application that would use AppFabric. Then, objects cached by, for example, application A wouldn't potentially lead to eviction of objects cached by application B. Perhaps I'm thinking about this incorrectly or there's another AppFabric feature that can accomplish this. Any insight would be appreciated.
回答1:
I'm afraid it's not possible to do this in AppFabric.
A named cache is a logical container for your data and each cache spans all cache hosts in the cluster. Because you can dynamically add/remove host in the cluster, it does not make sense to specify the size of a named cache.
That's why it is really important to plan your cache usage and also to monitor your cluster. One way to do this is through the performance counters (you can also get the size of a named cache).
The only one limit that you can specify is on a cache host (this will impact all configured named cache in the cluster) : it is only used for eviction. This feature is more related to health monitoring.
回答2:
For reference for those looking to change the cache for the whole cluster:
Changing the size on the host for all named caches
http://blog.milrr.com/2012/05/code-how-to-change-appfabric-cache-size.html
stop-cachecluster
set-cachehostconfig -HostName ENVY7-WIN8-2 -CachePort 22233 -CacheSize 1024
start-cachecluster
This sets a 1GB cache. Best practices suggest you shouldn't exceed 50% of your RAM as pointed out by @geo1701.
来源:https://stackoverflow.com/questions/13182648/how-to-set-windows-server-appfabric-named-cache-size