I am developing a web application with ASP.NET MVC 3 and Fluent NHibernate, in the future I will need to use more than one server because the user will double the amount of. How can I use this aproach, is it possible? How can I control the session between them?
1 Answer
Sure, it's possible. In order to be able to use the session you are going to need to move from InProc mode to SqlServer or StateServer.
Here's more detail about all the SessionState options you have: http://msdn.microsoft.com/en-us/library/ms178586.aspx
To use SqlServer follow the steps in this guide: http://support.microsoft.com/kb/317604
Also, bear in mind that objects that you put in the session must be marked as Serializable or else they won't be able to be stored in the database or State server.
4 Comments
Michel Andrade
Plablo, thanks! Is it possible to manage multiple databases too?
Pablo Romeo
You're welcome :). You mean one database per server? That's probably not what you'd want. Usually the database server is shared among all web-servers in the farm to feed off the same data. Both for sessions and the back-end database as well. You usually scale horizontally by adding more web servers behind a load balancer to be able to process more incoming requests, but your database server will need to be able to handle the load from all of them. You could however have Sql Server clusters and fail-over servers, but that is actually not my area of expertise :).
Pablo Romeo
Sure, no problem. If the answer was what you were looking for feel free to mark it as accepted ;)
Pablo Romeo
@MichelAndrade I just reread your question, and noticed that you might have been asking about the NHibernate Session, and not the ASP.NET Session. For NHibernate each web server would have it's own session, most likely using one of the common usage patterns, such as session-per-request or one of those.