I currently use Web Deploy, http://learn.iis.net/page.aspx/346/web-deploy/ to publish my MVC2 app. It used to work well, but now it is got to the point where I can't continue using it:
我目前使用Web Deploy,http://learn.iis.net/page.aspx/346/web-deploy/来发布我的MVC2应用程序。它曾经运作良好,但现在它已经达到我无法继续使用它的程度:
When the MVC app was small and had only a few users it was easy to publish. Just right click the project in Visual Studio and choose "Publish". And because there were only a few users it was easy to find a time when no one was using the site to do a quick update.
当MVC应用程序很小并且只有少数用户时,它很容易发布。只需在Visual Studio中右键单击该项目,然后选择“发布”。而且因为只有少数用户很容易找到没有人使用该网站进行快速更新的时间。
Then the app got bigger and had a few more users. The "Publish" action started taking longer and longer and occasionally timing out. Even when I recycled the app pool before deploy it still took a long time.
然后应用程序变得更大,并有更多的用户。 “发布”操作开始时间越来越长,偶尔会超时。即使我在部署之前回收了应用程序池,它仍然需要很长时间。
Also it became harder to find a time when no one was using the site so the update could be done without affecting anyone.
此外,当没有人使用该网站时,更难找到时间,因此可以在不影响任何人的情况下完成更新。
Then the "Publish" action started timing out every single time, and I had to switch to manual deployment as per this earlier unanswered question: Visual Studio 2010 - web deploy times out - what to do?
然后“发布”操作每次都开始计时,我不得不根据之前未解决的问题切换到手动部署:Visual Studio 2010 - Web部署超时 - 该怎么办?
Now the manual deploy is taking longer and longer, from 5 to 20 minutes. And the number of users has grown significantly, so the deployment always affects someone (slow response times, timeouts, site unavailable, etc)
现在手动部署需要更长时间,从5分钟到20分钟。并且用户数量显着增长,因此部署总是会影响某人(响应时间慢,超时,站点不可用等)
So what can I do? Is there a better alternative to using web deploy?
那我该怎么办?有没有比使用Web部署更好的替代方案?
Edit:
编辑:
Today's deployment took 18 minutes to publish just 49 changed files. The situation is just ridiculous and is one of the biggest weaknesses of our site right now. So I'm starting a decent sized bounty in the hopes of solving this.
今天的部署花了18分钟才发布了49个已更改的文件。这种情况很荒谬,是我们网站目前最大的弱点之一。因此,我希望能够解决这个问题,从而获得了不错的奖金。
Some more questions that may lead to a solution:
还有一些可能导致解决方案的问题:
- Why would it take so long when only a few files have been changed?
- 为什么只需要更改几个文件就需要这么长时间?
- Why does the web deploy zip always include the entire codebase and not just changed files?
- 为什么Web部署zip始终包含整个代码库而不仅仅是更改的文件?
- Why don't I just manually copy the changed files myself and skip the whole web deploy? But it is hard to manually work out what files have changed. I use SVN - does it have a way to output only files that have changed between two branches?
- 为什么我不自己手动复制更改的文件并跳过整个Web部署?但很难手动确定哪些文件已更改。我使用SVN - 它是否只能输出两个分支之间已更改的文件?
- What other questions should I be asking but haven't thought of yet?
- 我应该问什么其他问题,但还没有想到呢?
In reply to answers:
在回答答案:
Re: http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity_24.html This is exactly how I was doing the deploy, and would be an ideal method. Web deploy does correctly identify which files have changed, however it times out and no publish occurs. There are around 2500 files in the solution, perhaps it is taking too long to identify which ones are changed? Or it could be that publish has a short timeout value and that just uploading the 15mb zip file uses all that time up.
回复:http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity_24.html这正是我进行部署的方式,也是一种理想的方法。 Web部署可以正确识别哪些文件已更改,但是它超时并且不发生发布。解决方案中大约有2500个文件,可能需要很长时间才能确定哪些文件发生了变化?或者可能是发布具有短暂的超时值,并且只需上传15mb zip文件即可使用所有时间。
I do have full control over the server, and it does support web deploy. There are actually 2 servers: the primary live server, and a redundant server that we keep ready in case the first falls over. So any solution has to be easy to deploy to more than one server (web deploy was ideal until it stopped working).
我确实可以完全控制服务器,它确实支持Web部署。实际上有两台服务器:主服务器和一台冗余服务器,我们会在第一次服务器崩溃时做好准备。因此,任何解决方案都必须易于部署到多个服务器(Web部署是理想的,直到它停止工作)。
The suggestion of creating a new folder for each release and then just changing IIS to point to that new folder sounds like it will result in lower downtime/slowtime when during the publish. But it is a very manual process and I would prefer something more automated.
为每个版本创建一个新文件夹,然后只是将IIS更改为指向该新文件夹的建议听起来像是在发布期间会导致更短的停机时间/慢速时间。但这是一个非常手动的过程,我更喜欢更自动化的东西。
Edit #2
编辑#2
I have managed to narrow it down, and found exactly where it is slow - but not why. This is from the deploy log:
我已经设法缩小它,并找到它确切的缓慢 - 但不是为什么。这是来自部署日志:
[9/02/2011 12:11:56 a.m.] Performing synchronization pass #1.
[9/02/2011 12:11:56 a.m.] Parameter entry 'IIS Web Application Name/1' is applicable to 'iisApp/C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp' because of its scope.
[9/02/2011 12:11:56 a.m.] Parameter entry 'IIS Web Application Name/2' is applicable to 'setAcl/C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp' because of its scope.
[9/02/2011 12:11:56 a.m.] Parameter entry 'IIS Web Application Name/2' is applicable to 'setAcl/C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp' because of its scope.
[9/02/2011 12:11:56 a.m.] Parameter entry 'Add write permission to App_Data Folder/1' is applicable to 'setAcl/C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp\App_Data' because of its scope.
[9/02/2011 12:11:56 a.m.] Source createApp (C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp) does not match destination (Default Web Site/virtual-dir/) differing in attributes (isDest['False','True']). Update pending.
[9/02/2011 12:11:56 a.m.] Update operation on createApp (C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp) skipped because of rule CreateApplicationRule.
[9/02/2011 12:11:56 a.m.] Source filePath (C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp\App_Data\Create.sql) does not match destination (Default Web Site/virtual-dir/App_Data\Create.sql) differing in attributes (size['259691','259697'],lastWriteTime['02/08/2011 10:45:20','02/06/2011 03:48:16']). Update pending.
[400 lines of file updates skipped, time expired 2 seconds ....]
[9/02/2011 12:11:58 a.m.] Delete operation on filePath (Default Web Site/v2/zzz_app_offline.htm) skipped because of rule DoNotDeleteRule.
[9/02/2011 12:11:58 a.m.] Source setAcl (C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp) does not match destination (Default Web Site/virtual-dir/) differing in attributes (isDest['False','True'],setAclUser,setAclAccess). Update pending.
[9/02/2011 12:11:58 a.m.] Updating setAcl (Default Web Site/virtual-dir/).
[9/02/2011 12:13:47 a.m.] Source setAcl (C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp) does not match destination (Default Web Site/virtual-dir/) differing in attributes (isDest['False','True'],setAclUser,setAclAccess). Update pending.
[9/02/2011 12:13:47 a.m.] Updating setAcl (Default Web Site/virtual-dir/).
[9/02/2011 12:17:11 a.m.] Source setAcl (C:\src\Site.2010\Site.UI\obj\Release\Package\PackageTmp\App_Data) does not match destination (Default Web Site/virtual-dir//App_Data) differing in attributes (isDest['False','True'],setAclUser,setAclAccess). Update pending.
[9/02/2011 12:17:11 a.m.] Updating setAcl (Default Web Site/virtual-dir//App_Data).
[9/02/2011 12:17:11 a.m.] The dependency check 'DependencyCheckInUse' found no issues.
[9/02/2011 12:17:11 a.m.] The synchronization completed in 1 pass(es).
The cause of the slowness is the "Updating setAcl"
component. I am examining the ACLs of the development box and server box to see what is different. However it seems like an extremely bad idea to copy the ACL from a dev box to a server box! I already had the ACL set up just fine on the server.
缓慢的原因是“更新setAcl”组件。我正在检查开发盒和服务器盒的ACL,看看有什么不同。但是,将ACL从开发框复制到服务器框似乎是一个非常糟糕的主意!我已经在服务器上设置了ACL。
9 个解决方案
#1
2
I'd start by trying to isolate where the timeout is happening. You've mentioned a 15MB zip with 2,500 files which doesn't strike me as particularly large. Have you tried creating a deployment package in Visual Studio then running it directly on the server? This will take network latency out of the picture which is a pretty fundamental variable when it comes to timeouts.
我首先尝试隔离超时发生的位置。你已经提到了一个带有2,500个文件的15MB压缩文件,这对我来说并不特别大。您是否尝试在Visual Studio中创建部署包,然后直接在服务器上运行它?这将消除图像中的网络延迟,这在超时方面是一个非常基本的变量。
As for why a zip with the entire application needs to be uploaded, you need to remember the actual identification of what has changed and subsequent deployment into IIS all happens on the server. It's not Visual Studio or msdeploy on your local machine calling the shots on this.
至于为什么需要上传整个应用程序的zip,你需要记住实际识别已经改变的内容以及后续部署到IIS中的所有内容都发生在服务器上。在您的本地计算机上不是Visual Studio或msdeploy就此进行调用。
As for why you don't just manually copy the changed files over, it's summarised in my blog post you've referenced but in short, it's laborious and error prone. It means you need to consciously work through the thought process of "which of my 2,500 files just changed" rather than simply saying "make my target site match my development version". You haven't mentioned if you're publishing the web.config or not but obviously config transforms is another important reason why the simple CTRL-C then CTRL-V approach is cumbersome.
至于为什么你不只是手动复制已更改的文件,它总结在我引用的博客文章中,但总之,它很费力且容易出错。这意味着你需要有意识地完成“我刚刚改变了2,500个文件中的哪一个”的思维过程,而不是简单地说“让我的目标网站与我的开发版本匹配”。您还没有提到是否要发布web.config,但显然配置转换是简单的CTRL-C然后CTRL-V方法繁琐的另一个重要原因。
Trying to just take a change directly from SVN is also risky. Your first problem is you need to have complete confidence in the integrity and accuracy of the revision you're updating from if you're to get the appropriate changes published. You're then left with trying to sync these to the target and you're back at the same issues raised in the previous paragraph. The other big problem is versioning object code is always nasty; you'll be in a perpetual state of conflict with anyone else on the project and VCS is simply not intended to function this way.
试图直接从SVN进行更改也存在风险。您的第一个问题是,如果您要发布适当的更改,则需要对要更新的修订的完整性和准确性有完全的信心。然后,您将尝试将这些内容同步到目标,然后您回到上一段中提出的相同问题。另一个大问题是版本控制对象代码总是很讨厌;你将与项目中的任何其他人处于永久性冲突状态,而VCS根本不打算以这种方式运行。
My advice would be to focus on solving the root cause of the problem - Web Deploy is timing out - rather than simply trying to work around the symptoms. Manually publishing changes only or messing around with IIS bindings is only going to create more trouble for you in the long run and a lot more work in the immediate term. See how you go sharing the results of creating a package, copying it to the server then executing it locally and we'll take it from there. Once you have it working as designed, you should be seeing deployments no more than a few minutes and site outage measured in seconds.
我的建议是专注于解决问题的根本原因 - Web部署超时 - 而不是简单地尝试解决问题。仅手动发布更改或使用IIS绑定进行操作只会在长期内给您带来更多麻烦,而且在短期内会有更多工作。了解如何共享创建包的结果,将其复制到服务器然后在本地执行,我们将从那里开始。一旦您按设计工作,您应该看到部署时间不超过几分钟,并且站点中断以秒为单位进行测量。
BTW - You might also like to add what sort of latency you have between your PC and the server and how long it would normally take to transfer a 15MB file over HTTP.
顺便说一句 - 您可能还想添加PC和服务器之间的延迟,以及通过HTTP传输15MB文件通常需要多长时间。
#2
3
@JK from the info you provided it feels like a timeout issue. I agree with @TroyHunt 2500 files in 15 megs should delploy quickly. In particular the the output showing a delay while applying ACLs (whether or not they need to be changed). If it were me, I would start out doing some non-web deploy health checks. A few thoughts come to mind
@JK从你提供的信息感觉就像一个超时问题。我同意@TroyHunt 2500文件中的15兆应该快速部署。特别是输出在应用ACL时显示延迟(无论是否需要更改)。如果是我,我会开始做一些非Web部署健康检查。想到了一些想法
- are the webservers in a domain or workgroup?
- 是域或工作组中的Web服务器?
- what does
dcdiag
show ? - dcdiag显示什么?
- what does
netdiag
show ? - netdiag显示什么?
- are the dev boxes and the prod boxes in the same domain?
- 是同一个域中的开发盒和产品盒?
Is there a chance you are trying to apply users or groups that don't exist any more, are disabled , or come from domains other than the web server domain? It's possible your organization has a domain hierarchy with child domains or domain trusts, that are valid, but communication is blocked in the production data center.
您是否有可能尝试应用不再存在,被禁用或来自Web服务器域以外的域的用户或组?您的组织可能具有子域或域信任的域层次结构,这些域有效,但生产数据中心中的通信被阻止。
I think i would also manually look at the ACLs and see if there are entries that can't be resolved (they show up as SIDS before resolution).
我想我也会手动查看ACL并查看是否有无法解析的条目(它们在解析之前显示为SIDS)。
HTH, -eric
HTH,-eric
#3
1
If you have control over the server a really good option is to manually upload the zip. Unzip it and then use IIS manager to point to the new codebase. This way the downtime should be minimal. And if something goes wrong you have your last version intact and can just point IIS to that folder again.
如果你可以控制服务器,一个非常好的选择是手动上传zip。解压缩然后使用IIS管理器指向新的代码库。这样,停机时间应该是最小的。如果出现问题,您的最后一个版本保持不变,并且可以再次将IIS指向该文件夹。
On a shared host this won't work as well though. Maybe there is some way to adapt the same strategy by uploading the code and then rename folders to make it point to the new files.
在共享主机上,这不会起作用。也许有一些方法可以通过上传代码然后重命名文件夹来使其指向新文件来适应相同的策略。
Anyway it seems like web deploy should support sending only changed content. But I think you host need to support Web deploy in that case: http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity_24.html
无论如何,似乎Web部署应支持仅发送已更改的内容。但我认为在这种情况下你需要支持Web部署:http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity_24.html
If you don't have that I guess you could use a script to detect modifications in SVN. Here are some information about how to find changed files: http://blog.lysender.com/2010/11/svn-list-modified-files-between-revisions/ You would have to remember that codefiles are compiled into dll files so I would imagine something like this:
如果您没有,我猜您可以使用脚本来检测SVN中的修改。以下是有关如何查找已更改文件的一些信息:http://blog.lysender.com/2010/11/svn-list-modified-files-between-revisions/您必须记住,代码文件已编译为dll文件,因此我会想象这样的事情:
- Publish the website(Or use the files from statging server whatever makes most sense in your case)
- 发布网站(或者使用来自定位服务器的文件,在您的情况下最有意义)
- Have the script build a list of files to modifiy(translating code files to their dll)
- 让脚本构建一个文件列表来修改(将代码文件转换为它们的dll)
- Use an ftp that can be controled through the commandline to push the changes.
- 使用可以通过命令行控制的ftp来推送更改。
#4
1
Some other options you could consider:
您可以考虑的其他一些选项:
1) Deploy to a fresh directory each time and then switch between directories using IIS.
1)每次部署到一个新目录,然后使用IIS在目录之间切换。
2) Use a separate Subversion repository for your binaries. svn-load-dirs.pl can load the binaries in to subversion and can correctly mark files that have been added, removed or changed. You can run svn load-dirs on the end of your automated build process. The build process is the only 'user' checking into this repository and the production server is the only place checking it out so there are no versioning conflicts.
2)为二进制文件使用单独的Subversion存储库。 svn-load-dirs.pl可以将二进制文件加载到subversion中,并且可以正确标记已添加,删除或更改的文件。您可以在自动构建过程结束时运行svn load-dirs。构建过程是唯一检查此存储库的“用户”,生产服务器是检查它的唯一位置,因此没有版本控制冲突。
To deploy you simply svn update the working directory from the binary subversion repository. It efficiently copies down just the changed files in an atomic fashion (i.e. if the download fails it doesn't replace any files). If you find a problem right after deployment you can quickly go back to the previous version. If you want to update a single aspx file you can do a targeted svn update on that single file.
要部署你,只需从二进制subversion存储库svn更新工作目录。它以原子方式有效地复制已更改的文件(即,如果下载失败,则不会替换任何文件)。如果您在部署后立即发现问题,则可以快速返回到先前版本。如果要更新单个aspx文件,可以对该单个文件执行目标svn更新。
If you have TortoiseSVN installed on the server you can also see immediately if anyone has changed any files on the server without going through the correct build->checkin->deploy path.
如果您在服务器上安装了TortoiseSVN,您还可以立即看到是否有人更改了服务器上的任何文件,而无需通过正确的build-> checkin-> deploy路径。
The only caveat is that subversion doesn't handle binary diffs so your repository will grow rapidly, but you can simply wipe it and start again occasionally if that ever becomes a problem.
唯一需要注意的是,subversion不会处理二进制差异,因此您的存储库会快速增长,但您可以简单地擦除它并偶尔重新开始,如果它成为一个问题。
Another plus is that you have a complete record of every version you've ever deployed.
另一个好处是,您可以完整记录您已部署的每个版本。
I've used this technique for several projects and wish all deployment systems worked more like it: i.e. atomic update, easy to roll back, targeted single file update, complete version history, ...
我已经将这种技术用于多个项目,并希望所有部署系统都更像它:即原子更新,易于回滚,有针对性的单个文件更新,完整的版本历史,......
#5
1
Here's how I'm doing the publish:
这是我正在做的发布:
- I have a hook on teamcity and everytime I do a commit with svn it uses a rakefile to copy files to a dropbox folder where I also have a git repository.
- 我有一个关于teamcity的钩子,每次我用svn做提交它使用rakefile将文件复制到dropbox文件夹,我也有一个git存储库。
- Do a commit/push for the files that have been changed (for this git repository). I also have dropbox installed on the server
- 提交/推送已更改的文件(对于此git存储库)。我也在服务器上安装了Dropbox
- Pull changes from dropbox (with git) to a staging application to check things again.
- 将更改从dropbox(使用git)拉到暂存应用程序以再次检查。
- Once everything is ok for the staging application, i switch it with the production one from iis
- 一旦一切都适合登台应用程序,我就用iis的生产程序切换它
- When I want to publish again, once everything is synchronized with dropbox, i do a pull again, on the previous production which now becomes the staging one, and I switch again the applications.
- 当我想再次发布时,一旦所有内容与dropbox同步,我再次进行拉取,在之前的生产现在成为暂存,我再次切换应用程序。
Result->Users get 0 seconds downtime.
结果 - >用户获得0秒的停机时间。
If you want to cut some corners. You can do a git pull directly on the production site. Result->1 2 seconds downtime for users
如果你想削减一些角落。您可以直接在生产站点上执行git pull。结果 - > 1秒用户停机时间
If you really really want to cut some corners. You can install the dropbox folder directly into your production folder and dropbox will sync everything. Result 5 6 or more seconds downtime for users.
如果你真的想切一些角落。您可以将Dropbox文件夹直接安装到生产文件夹中,Dropbox将同步所有内容。结果5用户停机时间为6秒或更长时间。
#6
0
On the build/dev box, use command-line MSBuild to build the project's SLN (or wdproj). Make sure to precompile everything. Use a separate output path that you clean before the build. Get the results zipped up, and transfer that to the web server out-of-band (via UNC path or FTP server, or whatever). On the server, unzip and do a xcopy deploy.
在build / dev框中,使用命令行MSBuild构建项目的SLN(或wdproj)。确保预先编译所有内容。使用在构建之前清理的单独输出路径。压缩结果,并将其传输到带外的Web服务器(通过UNC路径或FTP服务器,或其他)。在服务器上,解压缩并执行xcopy部署。
To minimize transfer time, use rsync (there are versions for Windows), or use 7-zip with maximum settings to zip binaries.
要最小化传输时间,请使用rsync(适用于Windows的版本),或使用带有最大设置的7-zip来压缩二进制文件。
Server downtime is minimized since it would be only copying from local disk to local disk. Even though it's fast, the IIS app pool will recycle, to make up for that you'll need two machines behind a load balancer, so that you can update one while the other serves requests. (Maybe overkill, investigate using IIS's web-gardens)
服务器停机时间最小化,因为它只是从本地磁盘复制到本地磁盘。即使速度很快,IIS应用程序池也会回收,以弥补负载均衡器后面需要两台计算机,以便您可以在另一台服务请求时更新一台。 (也许是矫枉过正,使用IIS的网络花园进行调查)
To automate the process, use Powershell, or maybe even simpler, with batch files and PSExec for running remote commands.
要自动执行该过程,请使用Powershell,或者甚至更简单的方法,使用批处理文件和PSExec来运行远程命令。
#7
0
Why not use Dropbox?! Seriously....
为什么不使用Dropbox?!认真....
WARNING: THIS HASN'T BEEN TESTED BY ME, JUST AN HYPOTHETICAL ANSWER
警告:我没有经过我的测试,仅仅是一种假设的回答
Solution 1: In a non-professional way, I would install Dropbox on all servers including the staging server. And just web deploy from Visual studio to the staging.
解决方案1:以非专业的方式,我会在包括登台服务器在内的所有服务器上安装Dropbox。只需从Visual Studio进行Web部署即可。
Dropbox syncs files very quickly especially when you enable "Network downloading" where files get downloaded from local servers instead from dropbox!
Dropbox可以非常快速地同步文件,尤其是当您启用“网络下载”时,文件从本地服务器而不是从Dropbox下载!
Solution 2: Create deployment package from Visual Studio and save it to a local folder that syncs with dropbox. Then create a scheduled task that auto-runs deploy.cmd and clears the content of the deployment folder once done to avoid re-deploying over and over.
解决方案2:从Visual Studio创建部署包并将其保存到与dropbox同步的本地文件夹。然后创建一个自动运行deploy.cmd的计划任务,并在完成后清除部署文件夹的内容,以避免重复部署。
Problems with using Dropbox
使用Dropbox的问题
- ACL won't be synced :(
- ACL不会同步:(
- Remote desktop session should be always active as dropbox runs in the tray (not a service)
- 远程桌面会话应始终处于活动状态,因为dropbox在托盘中运行(不是服务)
- Folders should not contain any "data" files that gets changed or else conflicts will occur
- 文件夹不应包含任何更改的“数据”文件,否则将发生冲突
#8
0
I just had a similar issue where webdeploy began to take a very long time, especially when it got to "Updating setAcl"
. I was reluctant to disable updating the ACL as was suggested by some of the previous answers, especially when it worked fine deploying the same project to a different server.
我刚刚遇到类似的问题,其中webdeploy开始需要很长时间,特别是当它涉及“更新setAcl”时。我不愿意像以前的一些答案所建议的那样禁用更新ACL,特别是当它将同一个项目部署到不同的服务器时。
So I looked at what was different between the two target machines and the solution was pretty obvious in hindsight. On the production machine we had a lot of temporary local files that were being created and stored for a month (by design). I reduced the number of files, and the publish time went from 30 minutes to about 15 seconds.
所以我看看两台目标机器之间有什么不同,事后看来解决方案非常明显。在生产机器上,我们有很多临时本地文件正在创建和存储一个月(按设计)。我减少了文件数量,发布时间从30分钟缩短到大约15秒。
#9
-1
The fact that you are deploying from VS and not from a build/continuous integration server is the problem here.
您从VS而不是从构建/持续集成服务器部署的事实是这里的问题。
#1
2
I'd start by trying to isolate where the timeout is happening. You've mentioned a 15MB zip with 2,500 files which doesn't strike me as particularly large. Have you tried creating a deployment package in Visual Studio then running it directly on the server? This will take network latency out of the picture which is a pretty fundamental variable when it comes to timeouts.
我首先尝试隔离超时发生的位置。你已经提到了一个带有2,500个文件的15MB压缩文件,这对我来说并不特别大。您是否尝试在Visual Studio中创建部署包,然后直接在服务器上运行它?这将消除图像中的网络延迟,这在超时方面是一个非常基本的变量。
As for why a zip with the entire application needs to be uploaded, you need to remember the actual identification of what has changed and subsequent deployment into IIS all happens on the server. It's not Visual Studio or msdeploy on your local machine calling the shots on this.
至于为什么需要上传整个应用程序的zip,你需要记住实际识别已经改变的内容以及后续部署到IIS中的所有内容都发生在服务器上。在您的本地计算机上不是Visual Studio或msdeploy就此进行调用。
As for why you don't just manually copy the changed files over, it's summarised in my blog post you've referenced but in short, it's laborious and error prone. It means you need to consciously work through the thought process of "which of my 2,500 files just changed" rather than simply saying "make my target site match my development version". You haven't mentioned if you're publishing the web.config or not but obviously config transforms is another important reason why the simple CTRL-C then CTRL-V approach is cumbersome.
至于为什么你不只是手动复制已更改的文件,它总结在我引用的博客文章中,但总之,它很费力且容易出错。这意味着你需要有意识地完成“我刚刚改变了2,500个文件中的哪一个”的思维过程,而不是简单地说“让我的目标网站与我的开发版本匹配”。您还没有提到是否要发布web.config,但显然配置转换是简单的CTRL-C然后CTRL-V方法繁琐的另一个重要原因。
Trying to just take a change directly from SVN is also risky. Your first problem is you need to have complete confidence in the integrity and accuracy of the revision you're updating from if you're to get the appropriate changes published. You're then left with trying to sync these to the target and you're back at the same issues raised in the previous paragraph. The other big problem is versioning object code is always nasty; you'll be in a perpetual state of conflict with anyone else on the project and VCS is simply not intended to function this way.
试图直接从SVN进行更改也存在风险。您的第一个问题是,如果您要发布适当的更改,则需要对要更新的修订的完整性和准确性有完全的信心。然后,您将尝试将这些内容同步到目标,然后您回到上一段中提出的相同问题。另一个大问题是版本控制对象代码总是很讨厌;你将与项目中的任何其他人处于永久性冲突状态,而VCS根本不打算以这种方式运行。
My advice would be to focus on solving the root cause of the problem - Web Deploy is timing out - rather than simply trying to work around the symptoms. Manually publishing changes only or messing around with IIS bindings is only going to create more trouble for you in the long run and a lot more work in the immediate term. See how you go sharing the results of creating a package, copying it to the server then executing it locally and we'll take it from there. Once you have it working as designed, you should be seeing deployments no more than a few minutes and site outage measured in seconds.
我的建议是专注于解决问题的根本原因 - Web部署超时 - 而不是简单地尝试解决问题。仅手动发布更改或使用IIS绑定进行操作只会在长期内给您带来更多麻烦,而且在短期内会有更多工作。了解如何共享创建包的结果,将其复制到服务器然后在本地执行,我们将从那里开始。一旦您按设计工作,您应该看到部署时间不超过几分钟,并且站点中断以秒为单位进行测量。
BTW - You might also like to add what sort of latency you have between your PC and the server and how long it would normally take to transfer a 15MB file over HTTP.
顺便说一句 - 您可能还想添加PC和服务器之间的延迟,以及通过HTTP传输15MB文件通常需要多长时间。
#2
3
@JK from the info you provided it feels like a timeout issue. I agree with @TroyHunt 2500 files in 15 megs should delploy quickly. In particular the the output showing a delay while applying ACLs (whether or not they need to be changed). If it were me, I would start out doing some non-web deploy health checks. A few thoughts come to mind
@JK从你提供的信息感觉就像一个超时问题。我同意@TroyHunt 2500文件中的15兆应该快速部署。特别是输出在应用ACL时显示延迟(无论是否需要更改)。如果是我,我会开始做一些非Web部署健康检查。想到了一些想法
- are the webservers in a domain or workgroup?
- 是域或工作组中的Web服务器?
- what does
dcdiag
show ? - dcdiag显示什么?
- what does
netdiag
show ? - netdiag显示什么?
- are the dev boxes and the prod boxes in the same domain?
- 是同一个域中的开发盒和产品盒?
Is there a chance you are trying to apply users or groups that don't exist any more, are disabled , or come from domains other than the web server domain? It's possible your organization has a domain hierarchy with child domains or domain trusts, that are valid, but communication is blocked in the production data center.
您是否有可能尝试应用不再存在,被禁用或来自Web服务器域以外的域的用户或组?您的组织可能具有子域或域信任的域层次结构,这些域有效,但生产数据中心中的通信被阻止。
I think i would also manually look at the ACLs and see if there are entries that can't be resolved (they show up as SIDS before resolution).
我想我也会手动查看ACL并查看是否有无法解析的条目(它们在解析之前显示为SIDS)。
HTH, -eric
HTH,-eric
#3
1
If you have control over the server a really good option is to manually upload the zip. Unzip it and then use IIS manager to point to the new codebase. This way the downtime should be minimal. And if something goes wrong you have your last version intact and can just point IIS to that folder again.
如果你可以控制服务器,一个非常好的选择是手动上传zip。解压缩然后使用IIS管理器指向新的代码库。这样,停机时间应该是最小的。如果出现问题,您的最后一个版本保持不变,并且可以再次将IIS指向该文件夹。
On a shared host this won't work as well though. Maybe there is some way to adapt the same strategy by uploading the code and then rename folders to make it point to the new files.
在共享主机上,这不会起作用。也许有一些方法可以通过上传代码然后重命名文件夹来使其指向新文件来适应相同的策略。
Anyway it seems like web deploy should support sending only changed content. But I think you host need to support Web deploy in that case: http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity_24.html
无论如何,似乎Web部署应支持仅发送已更改的内容。但我认为在这种情况下你需要支持Web部署:http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity_24.html
If you don't have that I guess you could use a script to detect modifications in SVN. Here are some information about how to find changed files: http://blog.lysender.com/2010/11/svn-list-modified-files-between-revisions/ You would have to remember that codefiles are compiled into dll files so I would imagine something like this:
如果您没有,我猜您可以使用脚本来检测SVN中的修改。以下是有关如何查找已更改文件的一些信息:http://blog.lysender.com/2010/11/svn-list-modified-files-between-revisions/您必须记住,代码文件已编译为dll文件,因此我会想象这样的事情:
- Publish the website(Or use the files from statging server whatever makes most sense in your case)
- 发布网站(或者使用来自定位服务器的文件,在您的情况下最有意义)
- Have the script build a list of files to modifiy(translating code files to their dll)
- 让脚本构建一个文件列表来修改(将代码文件转换为它们的dll)
- Use an ftp that can be controled through the commandline to push the changes.
- 使用可以通过命令行控制的ftp来推送更改。
#4
1
Some other options you could consider:
您可以考虑的其他一些选项:
1) Deploy to a fresh directory each time and then switch between directories using IIS.
1)每次部署到一个新目录,然后使用IIS在目录之间切换。
2) Use a separate Subversion repository for your binaries. svn-load-dirs.pl can load the binaries in to subversion and can correctly mark files that have been added, removed or changed. You can run svn load-dirs on the end of your automated build process. The build process is the only 'user' checking into this repository and the production server is the only place checking it out so there are no versioning conflicts.
2)为二进制文件使用单独的Subversion存储库。 svn-load-dirs.pl可以将二进制文件加载到subversion中,并且可以正确标记已添加,删除或更改的文件。您可以在自动构建过程结束时运行svn load-dirs。构建过程是唯一检查此存储库的“用户”,生产服务器是检查它的唯一位置,因此没有版本控制冲突。
To deploy you simply svn update the working directory from the binary subversion repository. It efficiently copies down just the changed files in an atomic fashion (i.e. if the download fails it doesn't replace any files). If you find a problem right after deployment you can quickly go back to the previous version. If you want to update a single aspx file you can do a targeted svn update on that single file.
要部署你,只需从二进制subversion存储库svn更新工作目录。它以原子方式有效地复制已更改的文件(即,如果下载失败,则不会替换任何文件)。如果您在部署后立即发现问题,则可以快速返回到先前版本。如果要更新单个aspx文件,可以对该单个文件执行目标svn更新。
If you have TortoiseSVN installed on the server you can also see immediately if anyone has changed any files on the server without going through the correct build->checkin->deploy path.
如果您在服务器上安装了TortoiseSVN,您还可以立即看到是否有人更改了服务器上的任何文件,而无需通过正确的build-> checkin-> deploy路径。
The only caveat is that subversion doesn't handle binary diffs so your repository will grow rapidly, but you can simply wipe it and start again occasionally if that ever becomes a problem.
唯一需要注意的是,subversion不会处理二进制差异,因此您的存储库会快速增长,但您可以简单地擦除它并偶尔重新开始,如果它成为一个问题。
Another plus is that you have a complete record of every version you've ever deployed.
另一个好处是,您可以完整记录您已部署的每个版本。
I've used this technique for several projects and wish all deployment systems worked more like it: i.e. atomic update, easy to roll back, targeted single file update, complete version history, ...
我已经将这种技术用于多个项目,并希望所有部署系统都更像它:即原子更新,易于回滚,有针对性的单个文件更新,完整的版本历史,......
#5
1
Here's how I'm doing the publish:
这是我正在做的发布:
- I have a hook on teamcity and everytime I do a commit with svn it uses a rakefile to copy files to a dropbox folder where I also have a git repository.
- 我有一个关于teamcity的钩子,每次我用svn做提交它使用rakefile将文件复制到dropbox文件夹,我也有一个git存储库。
- Do a commit/push for the files that have been changed (for this git repository). I also have dropbox installed on the server
- 提交/推送已更改的文件(对于此git存储库)。我也在服务器上安装了Dropbox
- Pull changes from dropbox (with git) to a staging application to check things again.
- 将更改从dropbox(使用git)拉到暂存应用程序以再次检查。
- Once everything is ok for the staging application, i switch it with the production one from iis
- 一旦一切都适合登台应用程序,我就用iis的生产程序切换它
- When I want to publish again, once everything is synchronized with dropbox, i do a pull again, on the previous production which now becomes the staging one, and I switch again the applications.
- 当我想再次发布时,一旦所有内容与dropbox同步,我再次进行拉取,在之前的生产现在成为暂存,我再次切换应用程序。
Result->Users get 0 seconds downtime.
结果 - >用户获得0秒的停机时间。
If you want to cut some corners. You can do a git pull directly on the production site. Result->1 2 seconds downtime for users
如果你想削减一些角落。您可以直接在生产站点上执行git pull。结果 - > 1秒用户停机时间
If you really really want to cut some corners. You can install the dropbox folder directly into your production folder and dropbox will sync everything. Result 5 6 or more seconds downtime for users.
如果你真的想切一些角落。您可以将Dropbox文件夹直接安装到生产文件夹中,Dropbox将同步所有内容。结果5用户停机时间为6秒或更长时间。
#6
0
On the build/dev box, use command-line MSBuild to build the project's SLN (or wdproj). Make sure to precompile everything. Use a separate output path that you clean before the build. Get the results zipped up, and transfer that to the web server out-of-band (via UNC path or FTP server, or whatever). On the server, unzip and do a xcopy deploy.
在build / dev框中,使用命令行MSBuild构建项目的SLN(或wdproj)。确保预先编译所有内容。使用在构建之前清理的单独输出路径。压缩结果,并将其传输到带外的Web服务器(通过UNC路径或FTP服务器,或其他)。在服务器上,解压缩并执行xcopy部署。
To minimize transfer time, use rsync (there are versions for Windows), or use 7-zip with maximum settings to zip binaries.
要最小化传输时间,请使用rsync(适用于Windows的版本),或使用带有最大设置的7-zip来压缩二进制文件。
Server downtime is minimized since it would be only copying from local disk to local disk. Even though it's fast, the IIS app pool will recycle, to make up for that you'll need two machines behind a load balancer, so that you can update one while the other serves requests. (Maybe overkill, investigate using IIS's web-gardens)
服务器停机时间最小化,因为它只是从本地磁盘复制到本地磁盘。即使速度很快,IIS应用程序池也会回收,以弥补负载均衡器后面需要两台计算机,以便您可以在另一台服务请求时更新一台。 (也许是矫枉过正,使用IIS的网络花园进行调查)
To automate the process, use Powershell, or maybe even simpler, with batch files and PSExec for running remote commands.
要自动执行该过程,请使用Powershell,或者甚至更简单的方法,使用批处理文件和PSExec来运行远程命令。
#7
0
Why not use Dropbox?! Seriously....
为什么不使用Dropbox?!认真....
WARNING: THIS HASN'T BEEN TESTED BY ME, JUST AN HYPOTHETICAL ANSWER
警告:我没有经过我的测试,仅仅是一种假设的回答
Solution 1: In a non-professional way, I would install Dropbox on all servers including the staging server. And just web deploy from Visual studio to the staging.
解决方案1:以非专业的方式,我会在包括登台服务器在内的所有服务器上安装Dropbox。只需从Visual Studio进行Web部署即可。
Dropbox syncs files very quickly especially when you enable "Network downloading" where files get downloaded from local servers instead from dropbox!
Dropbox可以非常快速地同步文件,尤其是当您启用“网络下载”时,文件从本地服务器而不是从Dropbox下载!
Solution 2: Create deployment package from Visual Studio and save it to a local folder that syncs with dropbox. Then create a scheduled task that auto-runs deploy.cmd and clears the content of the deployment folder once done to avoid re-deploying over and over.
解决方案2:从Visual Studio创建部署包并将其保存到与dropbox同步的本地文件夹。然后创建一个自动运行deploy.cmd的计划任务,并在完成后清除部署文件夹的内容,以避免重复部署。
Problems with using Dropbox
使用Dropbox的问题
- ACL won't be synced :(
- ACL不会同步:(
- Remote desktop session should be always active as dropbox runs in the tray (not a service)
- 远程桌面会话应始终处于活动状态,因为dropbox在托盘中运行(不是服务)
- Folders should not contain any "data" files that gets changed or else conflicts will occur
- 文件夹不应包含任何更改的“数据”文件,否则将发生冲突
#8
0
I just had a similar issue where webdeploy began to take a very long time, especially when it got to "Updating setAcl"
. I was reluctant to disable updating the ACL as was suggested by some of the previous answers, especially when it worked fine deploying the same project to a different server.
我刚刚遇到类似的问题,其中webdeploy开始需要很长时间,特别是当它涉及“更新setAcl”时。我不愿意像以前的一些答案所建议的那样禁用更新ACL,特别是当它将同一个项目部署到不同的服务器时。
So I looked at what was different between the two target machines and the solution was pretty obvious in hindsight. On the production machine we had a lot of temporary local files that were being created and stored for a month (by design). I reduced the number of files, and the publish time went from 30 minutes to about 15 seconds.
所以我看看两台目标机器之间有什么不同,事后看来解决方案非常明显。在生产机器上,我们有很多临时本地文件正在创建和存储一个月(按设计)。我减少了文件数量,发布时间从30分钟缩短到大约15秒。
#9
-1
The fact that you are deploying from VS and not from a build/continuous integration server is the problem here.
您从VS而不是从构建/持续集成服务器部署的事实是这里的问题。