1

Basically my question is i have a website which was developed around 3 years ago, while development it was proposed that this site will be used by few people on internet.

But now it seems like many users are accessing the website. So we have planned to create a Web sever Farm where we have multiple servers for our website.

major problem in development is old website used InProc Session state and now since we are upgrading to multiple servers we want to change InProc to Outproc i.e StateServer Session State.

Can you guide me on this upgrade and how can it be achieved in simple and easy way rather than changing the coding on each pages wherever sessions are used.

Murtaza
  • 3,045
  • 2
  • 25
  • 39
  • you mean that you setup an SQL to keep the session state, right ? – Aristos Mar 27 '12 at 10:46
  • ya it can be SQLServer or StateServer any which every is more efficient. i m confused in @MassimilianoPeluso answer what does he mean to serialization? – Murtaza Mar 27 '12 at 10:49
  • that's what MSDN says :Objects stored in session state must be serializable if the mode is set to StateServer. For information on serializable objects, see the SerializableAttribute class. – Massimiliano Peluso Mar 27 '12 at 10:54
  • I do not know ether :) The serializable is used when you 'serialize' and save data that way, nothing to do what you actually ask. – Aristos Mar 27 '12 at 10:54
  • @Aristos have a look at the MSDN :http://msdn.microsoft.com/en-us/library/ms178586.aspx – Massimiliano Peluso Mar 27 '12 at 10:56
  • @Aristos - so can you guide to what i need? as i am not sure what step should i take. or is it possible to change the session state from one to another for live website. – Murtaza Mar 27 '12 at 10:58
  • @MassimilianoPeluso Look, if some one save data to the session and this data is a class or a List or anything like that, he need to make them serialize anyway, nothing to do what murtaza ask here. – Aristos Mar 27 '12 at 11:01
  • if you read on MDSN it states the all the objects in the session MUST be serializable(if you are using SQL Server state or State Server)Now if @Murtaza is gonna use State Server or Sql State Server and any of the object that he used to store in the session is not Serailizable it will throw an Expcetion – Massimiliano Peluso Mar 27 '12 at 11:02
  • @MassimilianoPeluso if you save a string, or an int you do NOT need to place any serialize to that, only if you make any List data. The string, int etc no need. The session state are saved on a Dictionary. Maybe you have confuse something here. – Aristos Mar 27 '12 at 11:09
  • @Aristos I know that I was just reporting what MSDN says about that Please have a look at that link you will find a NOTE regarding that – Massimiliano Peluso Mar 27 '12 at 11:11

1 Answers1

1

What you going to have here is that you move your site to many web servers and the actual issue here is "how to keep the same state for each user regarding the server".

There are two options.

First option is to setup the router that split the users to the server, to use the "Sticky option", meaning that each user is stick for his session to one server, and one only. In this case it did not matter if you use inproc or sql server session, as long as the router make good job. This is the case of course that you do not use any other database for common data.

Second option is to use an sql server and move the session to the server, but here the server must be on one server and the others server's gets his session data from this one. Also you setup on web.config the same key machine for all web servers.

So for this case you need.

  1. To setup a common/shared SQL server on one server
  2. To install on this the session database (actually run a script from asp.net)
  3. Setup the web.config to use this database as session
  4. Setup the web.config to have the same machine key.

In the case that you use a database for other data, then you place this database together with the session database, and you make a share connect to that database also. The point here is that the data must be live on one computer, and the other computers connect to this main one for the data.

Aristos
  • 66,005
  • 16
  • 114
  • 150
  • thats pretty clear! but i want to ask you what about all those sessions which are already created. If i make this change in `web.config` my current code lines will give error? – Murtaza Mar 27 '12 at 11:10
  • @Murtaza The sessions that all ready created they will be lost and new one will be made. No the sessions are working the same regardless the medium that you use – Aristos Mar 27 '12 at 11:33
  • That really mindblowing answer... Thank you so much. Hope this is usefull to many people – Murtaza Mar 27 '12 at 11:59