Deploying an ASP.NET MVC in production, while users are still online
Asked Answered
D

2

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?

Detruncate answered 17/12, 2013 at 23:2 Comment(6)
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 informationAronow
Define "connected to it". Do you use in-proc session?Vannessavanni
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.Deirdra
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.Giess
@LukeHutton Yes, I do use in-proc sessions. ie: Session["CurrentUserId"] = 9234Detruncate
@Aronow 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.Detruncate
V
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.

Vannessavanni answered 19/12, 2013 at 0:47 Comment(0)
T
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/

Teodorateodorico answered 16/11, 2016 at 5:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.