更新在 IIS 上运行的实时网站的最佳实践
目前,当我们想要将更新发布到实时网站时,我们会运行一个 .bat 文件,将整个文件夹结构从开发环境复制到实时服务器。这会将虚拟目录指向的文件夹替换为新更新的文件夹。这是在服务器和 IIS 运行时完成的,显然是在用户访问网站时完成的。
我们偶尔会遇到由于文件或文件夹在更新后立即“锁定”而导致的错误,通常唯一的选择是停止 IIS 或重新启动服务器。我们猜测这种“锁定”是由 .bat 文件在 IIS 使用该文件时尝试覆盖该文件引起的。
有没有其他人经历过这种情况和/或您会推荐什么作为以最少的停机时间(即几乎没有停机时间)动态更新实时网站的最佳方法。
谢谢。
Currently, when we have updates that we want to roll out to our live website, we run a .bat file that copies the entire folder structure up from our development environment to the live servers. This replaces the folder that the virtual directory points to with the new updated new one. This is done while the server and IIS are live and obviously while users are accessing the website.
We occasionally get errors that are caused by files or folders becoming 'locked' immediately after an update, and usually the only option is to stop IIS or reboot the server. We're guessing that this 'locking' is caused by the .bat file attempting to overwrite a file while it is in use by IIS.
Has anybody else experienced this and/or what would you recommend as the best way to update a live website on the fly with minimal downtime (i.e. almost no downtime at all).
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
重新发布为答案而不是评论,在那里度过了一个愚蠢的时刻!
如果您不能停机,那么最好的办法是运行服务器的另一个副本,当您想要更新主服务器时,您可以将用户转移到该副本。然后,您可以在更新后将用户转移回主系统。
您可以使用位于另一台服务器上的状态服务器来确保从一台服务器切换到另一台服务器时维持任何会话状态。
我们目前正在试验微软的Web Farm Framework,它似乎可以很好地完成这种事情。
我们的设置包括一个前端服务器、一个主要和辅助 Web 服务器以及一个单独的状态服务器。 WFF 使 Web 应用程序的副本在两台计算机上保持同步,并且状态服务器确保如果用户在请求之间切换服务器(或者当前服务器脱机),他们不会注意到更改。
要升级主服务器,请将其退出负载平衡,这会将其所有请求转移到辅助服务器。进行升级,将其重新投入循环,然后对第二台服务器重复该过程。
Reposted as an answer rather than a comment, was having a stupid moment there!
If you can't have downtime, then the best thing is to have another copy of the server running that you can divert users to when you want to update the primary. Then you divert your users back to the primary after the update.
You can use the State Server sitting on another server to ensure that any session state is maintained when they switch from one to the other.
We are currently experimenting with Microsoft's Web Farm Framework, which seems to do this kind of thing very well.
Our setup involves a front end server, a primary and secondary web server, and a separate state server. WFF keeps copies of web apps in sync on both machines and state server ensures that if a user switches servers between requests (or their current server goes offline), that they should not notice the change.
To upgrade the primary, take it out of load-balancing which will divert all of it's requests to the secondary server. Do your upgrade, put it back in to rotation, and then repeat the process with the second server.
购买第二个网络服务器,购买负载平衡器。将 1 个服务器标记为离线、升级、恢复在线。将服务器 2 标记为离线、升级、恢复在线。
Buy a second webserver, buy a load balancer. Mark 1 server offline, upgrade, bring back online. Mark server 2 offline, upgrade, bring back online.
另一种选择是为每个部署交替使用两个文件夹,例如蓝绿部署。因此,当蓝色文件夹当前处于活动状态时,您可以将新的代码库部署到绿色文件夹,然后在准备就绪时更改 IIS 设置以指向绿色文件夹。
Another option is to have two folders that you alternate between for every deployment, like in blue-green deployment. So when the blue folder is currently live, you deploy the new codebase to the green folder and then when it is ready you change the IIS settings to point to the green folder.