views:

101

answers:

1

Hi,

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 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

+1  A: 

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.

Darin Dimitrov
Thx for your reply.We're not using the spring container as a cache, but one the managed objects can have cached data.Is it bad practise to store data in ddd-repositories? And why is that? (besides the fact that the application spreads over multiple webservers)
Bert Vandamme
Because storing data in objects means storing it in memory. In case you have lots of data memory usage might become high on your servers. Another issue is cache distribution. In a webfarm scenario you will need to keep this data in sync which is what distributed cached systems are meant for.
Darin Dimitrov