Session in a database

Asked

Viewed 624 times

2

Thinking about the scalability of applications developed in , I searched for alternatives not to use "session in memory".

I saw that it is possible to save session data in database and use SQL Server as state server, but also saw that there is ASP.NET State Service, which is a Windows service that serves exclusively to manage the ASP.NET Session environment.

Which of these alternatives is recommended?

1 answer

1


It depends on what your application needs. The question "which alternative is recommended" is very categorical, so I won’t answer it directly. I’ll tell you a little bit about each model and you should decide which one is more interesting:

  • In process: is the default, the session is stored within the Application Pool process. If you only have one web server or if the session status is not important (the client being redirected to another server, for example), then this is a good option
  • State server: you use another server to maintain session status. Allows you to have N application servers sharing the same sessions, allowing a client to be routed to different servers between requests without their notice. However, the session is still in memory. If there is a server failure, it will be lost. This risk also occurs in the first model.
  • SQL Server: sessions are persisted in a table. It allows you to have N application servers sharing the same sessions. As the session is persisted, it will be maintained even if there is a failure in the servers. However, this option is slower than State Server, because there is the cost of the database. In addition, sessions are all in a notary, which can be a problem if you have a very high volume of users.

I think which, for your case, the most recommended is the State server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.