8

What is the best way to deploy changes to a website( replace the dlls and other required files) ?

Should the website be stopped and started or should the app pool be stopped and started?

I read that when a website is stopped, it still has the application state loaded in memory. In this case will the old request be served ? Can the dlls be replaced without any problem ? How does the content gets reloaded when the website is started?

When the app pool is stopped, will it continue to serve the old requests? If yes, how does the old request gets served considering the website is now containing the changed dlls?

Tulika
  • 360
  • 5
  • 16

2 Answers2

4

What is the best way to deploy changes to a website( replace the dlls and other required files) ?

The best way is to use Web Deploy to automate the process. It automatically compares files and only replaces what is needed and deletes what is not needed, making it very fast, efficient, and reliable.

Should the website be stopped and started or should the app pool be stopped and started?

You typically don't have to do either. However, if you want to prevent access to your website during an upgrade and the upgrade is expected to take longer than a few seconds, then you could stop the web site and start another one that uses the same IIS bindings with an "Application Under Maintenance" message.

I read that when a website is stopped, it still has the application state loaded in memory. In this case will the old request be served ? Can the dlls be replaced without any problem ? How does the content gets reloaded when the website is started?

The HTTP protocol is stateless. So, most content that is updated will be reloaded from the new files on the server.

There are a few exceptions.

If you are using out-of-process session state, the state will be persisted even though the application is recompiled and reloaded. Typically, the data that you have in session state is something you want to survive an upgrade, though.

If you are using caching (System.Web.Caching or System.Runtime.Caching), the cached data will remain if you specified to make it "Not Removable". Typically, I use a single file for the application as a cache dependency so when that file is edited (or replaced) on the server, the cache will be reset.

Output caching has no cache dependencies. Normally it survives until the application pool is restarted. But, you could see this answer for a manual way to reset it without an application pool reset.

Cookies are stored on the remote client machines. Therefore, they will survive an upgrade intact.

Static files (images, css, and javascript files) are typically cached on the remote client machines. So when you do an upgrade, it is helpful to append a query string to the end of these URLs to ensure the cached file is not used. See this article for one such approach.

When the app pool is stopped, will it continue to serve the old requests? If yes, how does the old request gets served considering the website is now containing the changed dlls?

As I already mentioned, the HTTP protocol is stateless. The server will not replay any former requests that were made by clients. Once the client has received the repsponse, the server essentially forgets about them.

A lot of the way the web server handles an upgrade is determined by whether it is a web application or a web site (and if a web site, whether it has been precompiled). If the application is running during an upgrade, users that try to access it could see errors.

My advice is: don't worry about it. Schedule your upgrades for off-peak times. Use Web Deploy to automate the process to make the upgrade window as short as possible. And use the techniques above to ensure cached data and content is reset appropriately. In most applications, a few seconds or minutes of downtime in the middle of the night goes almost unnoticed.

Community
  • 1
  • 1
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
  • Thanks for the reply. In our case we don’t have any maintenance window for deployment so the offline message is not an option for us. We take batch of servers out of LB and then wait for the connections to drain. When the connections are very less, we start deployment on these servers. So i wanted to understand that in this case, what is the best way for deployment? In case the app pool is stopped and then started, what happens to the old connections which were still there when the deployment started? Would they be served or not? – Tulika Mar 17 '15 at 23:24
  • In case of app pool recycle, due to on demand recycle, the old connections should be served. But I want to understand that when I have replaced the dlls in the website folder, how are the requests served for the old connection? are they cached in memory ? – Tulika Mar 17 '15 at 23:24
0

first off I don't like web deploy it requires to many things installed and managed on your servers. it's also more complicated then it needs to be. (my opinion) I was reading your comments:

the following options are need for what you want to do: archecture: you need to be running 2 site server stacks with a load balancer of some kind. (web front and middleware or whatever your doing)

take one stack off line from the firewall, leave application live on the other side check your logs to ensure transactions have completed on the site your deploying to.

do your deployment:

Stop Web Site/service (AppPool) REMOVE all existing files related to that web service/site your udpateing use xCopy to install all files (or zip extract to target will also work) start web site/service (AppPool) test from inside network to ensure it works deployment completed.

turn off access to other site and activate site (or sties) you have completed (at the firewall load balancer. this will allow existing transactions to complete and will make your new code live.

there is more items that should be looked at in your deployment however this should get you started. cheers and luck!

Kelly Davis
  • 354
  • 2
  • 6