asp.net - 为什么 IIS 比 ASP.NET 开发服务器慢?

标签 asp.net performance iis cassini

我有一个 ASPX 网页,可以执行一些复杂的操作和数据库调用。当我通过运行 ASP.NET Development Server (Cassini) 查看网页时,大约需要 200 毫秒。

然后,没有任何代码更改和配置更改,我将网站部署到我的本地机器 IIS 7 并再次查看相同的网页。需要 2.0 秒,即 慢 10 倍 .

我认为 IIS 应该比(或至少和)Cassini 一样快。

为了进一步调查,我创建了一个新页面 test1.aspx,其中只包含一个空的 for 循环,该循环在 Page_Load 中运行了 9000 万次。在 Cassini 中,大约需要 200 毫秒。在 IIS 中,它需要 300 毫秒(慢 50%)。

使 IIS 比 Cassini 慢的原因可能是什么?或者,也许是一个更好的问题,我怎样才能使 IIS 的运行速度至少与 Cassini 一样快?

最佳答案

快速而简短的回答:
配置 Web 应用程序使用的应用程序池以启用 32 位应用程序:
Set Enable 32-bit applications to True
详细攻略:
我用了一些 performance profiling tools (有些是 free )来比较性能并找出瓶颈。免费 EQATEC Profiler足以让我比较运行 Cassini 和 IIS 生成的两个报告,并确定导致问题的方法。但是,该方法包含太多行,我无法查明导致问题的确切行。
然后 Redgate ANTS派上用场了。通过使用行级细节分析该方法,我发现它的 RegEx 运行非常缓慢。
进一步搜索将我带到这里的答案:RegEx.Match is much slower in IIS compared to Development Server (Cassini) .我正在使用带有 IIS 7 的 Windows 7 64 位。将“启用 32 位应用程序”设置为 True 可以解决问题。

此外,关于将 IIS 运行为 32 位或 64 位的稍微相关的阅读:

64-bit servers are much more effective when used for databases like SQL Server, or other data management servers (let's say, an enterprise email server like Exchange), than for processing servers, such as IIS or the worker processes it manages.

It will require 64-bit pointers for every lookup, which will make everything a little slower.


来源:What are the pros and cons of running IIS as 32bit vs 64bit on a 64bit OS?

关于asp.net - 为什么 IIS 比 ASP.NET 开发服务器慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12954150/

相关文章:

.net - ASP.NET奇怪的编译错误

c# - ASP.NET 样板文件 : How do I inject object of DbContext in application service?

c# - 使用 C# 的 SQL Azure 数据库备份和还原

c# - 如何在业务层和/或数据层使用 Entity Framework ?

javascript - 如何在IE中设置HTML下拉列表的innerHTML

performance - 加快矩阵计算

java - PostgreSQL 多个 'WHERE' 条件(1000+)请求

c++ - 循环效率: merging loops

由 iis 7.5 或 consolehost 托管的带有 SSL 的 WCF

asp.net - ASP.NET 开发服务器在哪里保存其日志?