开发者

spring.net application scope repository object on loadbalanced application

We have an application running on a loadbalanced environment, let say webserver A and B. The loadbalancing is on the HTTP level, so the loadbalancer directs each user request to one of both webservers.

The scope of the repositories in the application is managed by the spring.net container, and the application relies on data that can be cached by the repository (performance reasons).

In this case we can never be sure that the cached data in the repositories on both webservers is the same.

Is there 开发者_Python百科mechanism in spring.net that can manage this kind problem? Or is there another common approach for this kind of thing?

Any ideas?

Thx,

Bert


Spring.NET is an object container. It is not intended to be used as a caching container therefore you should not store your data in the repositories. What you need in this case is a distributed caching solution such as memcached. It has a .NET client library also.

So basically your repositories will first look in the distributed cache if the object exists and if not then hit the real data store in order to get the object and store it into the cache. Spring.NET will handle the lifetime of these repositories and as you are running in a webfarm you will have a repository per server but this won't be an issue because these repositories will use a distributed cache to fetch data so you will get consistent resylts between all the servers in the farm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜