6

I need to know the best practices for deploying a new version of an ASP.NET MVC application while users are still connected to it

Everytime one deploys the .dll that contains the models and controllers of the application, the application is rebooted. Also deploying the web.config (that references eventually new libraries) results in rebooting the application.

So, the question is: how do I update the application's dll or web.config without disconnecting the users from the site?

sports
  • 6,889
  • 11
  • 61
  • 121
  • What youre looking for is hot deploy, which honestly (I don't know much) but I really think that this question belong to serverfault, where you can find more information – Jorge Dec 17 '13 at 23:05
  • 1
    Define "connected to it". Do you use in-proc session? – Luke Hutton Dec 17 '13 at 23:05
  • If the "session model" changes this may not be possible because even if you preserve your user's session the objects stored in it may become invalid. – Thomas C. G. de Vilhena Dec 17 '13 at 23:20
  • 1
    A lot of sites post a notification on the page 10 minutes (or whatever) before taking the site down for maintenance. Other than that it's going to be load balancing but eventually you will have to kick your users out to update code. You can't update code without restarting the app that uses the code. And if you can I eagerly await the solution as well. – Mike Cheel Dec 17 '13 at 23:31
  • @LukeHutton Yes, I do use in-proc sessions. ie: Session["CurrentUserId"] = 9234 – sports Dec 18 '13 at 16:12
  • @Jorge thanks for the concept ("hot deploy"), I will research about it. Although, I don't agree that this question should belong to serverfault, because there are programming things involved, as what to do with the sessions, or current operations running. – sports Dec 18 '13 at 16:14

2 Answers2

1

You want to use another session state option other than using in-proc so your users survive when the process recycles or system reboots.

InProc: In-Proc mode stores values in the memory of the ASP.NET worker process. Thus, this mode offers the fastest access to these values. However, when the ASP.NET worker process recycles, the state data is lost.

See ASP.NET Session State Options for more ASP.NET options and mentions of other third party session state providers.

This question also deals with possible deployment scenarios to help with the websites under load and slow app times after a pool recycle: How are people solving app pool recycle issues on deployment with large apps?

Ideally you want to be as stateless as you can, and stay away from session. Perhaps you can use a cookie for tracking the current user via forms auth for example. But you must stay away from in-proc by using distributed cache/session provider so users won't lose session state on app pool recycles.

Community
  • 1
  • 1
Luke Hutton
  • 9,906
  • 6
  • 28
  • 54
1

I think the best is to deploy a new site for new sessions, and mantain existing sessions in the old one.

I feel that "The blue green deployment strategy" article linked below can be hacked with a few changes to do that (Disallow New Connections instead of issue a "drain", using sticky sessions).

https://kevinareed.com/2015/11/07/how-to-deploy-anything-in-iis-with-zero-downtime-on-a-single-server/

Cesc
  • 11
  • 1