Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# gedw99 3/9/2007 8:43 AM
Hey,

I need to scale out to 2 web servers connected to a single db.

i am wondering about the caching and state management issues.
If a row is added in the DB by server01, server02 wont see it UNTIL it refreshes it cache right?
So when will it do that?
For example in this code, sure its caching, but where is the time that its cached for. I think there is somehting i am missing about nhibernate here.

public Node GetNodeByShortDescriptionAndSite(string shortDescription, Site site)
{
ISession session = this._sessionManager.OpenSession();

string hql = "from Node n where n.ShortDescription = :shortDescription and n.Site.Id = :siteId";
IQuery q = session.CreateQuery(hql);
q.SetString("shortDescription", shortDescription);
q.SetInt32("siteId", site.Id);
q.SetCacheable(true);
q.SetCacheRegion("Nodes");
IList results = q.List();
if (results.Count == 1)
{
return (Node)results[0];
}
else if (results.Count > 1)
{
throw new Exception(String.Format("Multiple nodes found for ShortDescription {0}. The ShortDescription should be unique.", shortDescription));
}
else
{
return null;
}
}


And what about state between requests? Does the load balancer HAVE TO use "Sticky" or is round robin ok.

I am kind of confused how under the hood NHibernate manages it state you see.

Ged
# gedw99 3/12/2007 4:09 PM
Have not got any answers on this one.

Let me ask it simply:
Is session state held in the web server between request / responses cycles. i need to know so i can configure the DNS and load balancer to either do Round robin or Sticky algorithms.



# martijnb 3/13/2007 5:16 PM
Currently, Cuyahoga holds no session state.

If you want to use a second-level cache implementation for multiple web servers, it might be possible to use the memcached second-level cache provider that comes with NHibernate. Haven't any experience with this, so nothing is guaranteed here.
# gedw99 3/14/2007 8:01 PM
thanks - thats great.