生产服务器上的 ASP.NET 网站性能缓慢

发布于 2024-08-03 06:45:56 字数 254 浏览 5 评论 0原文

我的问题是,与开发服务器上相比,我的 ASP.NET 网站在生产服务器上的运行速度较慢。

在我的开发环境中执行时间为 120 毫秒的页面需要 400 毫秒才能在服务器上执行。我已经使用探查器监视了 SQL 服务器,并且在服务器上花费 400 毫秒的页面上运行的查询只需要大约 50 毫秒即可完成 - 所以我确信我的问题不在于 SQL 服务器。

我的开发机器是具有 6GB RAM 的 Intel I7,生产服务器是具有 16GB RAM 的 2x AMD 四核。

My problem is that my ASP.NET website is running slower on my production server comparatively on my development server.

A page that executes in 120ms in my development environment takes 400ms to execute on the server. I've monitored the SQL server with the profiler and the query being run on the page taking 400ms on the server only takes around 50ms to finish - so I've convinced myself that my problem does not lie with the SQL server.

My development machine is an Intel I7 with 6GB RAM, the production server is a 2x AMD Quad Core with 16GB ram.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

清风疏影 2024-08-10 06:45:56

您可以考虑一些要点来提高网站的性能。

  1. 设置 debug=false
  2. 除非需要,否则关闭跟踪
  3. 如果不需要,则关闭会话状态。
    ASP.NET 自动管理会话状态。但是,如果您不需要会话,禁用它将有助于提高性能。
  4. 在不需要时禁用 ViewState。
  5. 避免频繁往返数据库
  6. 避免引发异常。
    异常是处理应用程序逻辑中发生的错误的好方法。然而,抛出异常是一种昂贵的资源,必须避免。使用特定的异常并尽可能少地使用以避免资源开销
  7. 使用缓存来提高应用程序的性能。
  8. 使用Finally方法杀死资源

编辑:
使用此网站衡量您的网站性能
http://www.websiteoptimization.com/services/analyze/


http://www.websitepulse.com/

There are some point you can consider for performance improvment of your website.

  1. Set debug=false
  2. Turn off Tracing unless until required
  3. Turn off Session State, if not required.
    ASP.NET Manages session state automatically. However, in case you dont require Sessions, disabling it will help in improving the performance
  4. Disable ViewState as and when not required.
  5. Avoid Frequent round trips to the Database
  6. Avoid Throwing Exceptions.
    Exceptions are a greate way to handle errors that occur in your application logic. However, throwing exceptions is a costly resource and must be avoided. Use specific exceptions and use as minimal as possible to avoid resource overhead
  7. Use Caching to improve the performance of your application.
  8. Use Finally Method to kill resources

Edit:
measure your website performance using this website
http://www.websiteoptimization.com/services/analyze/


http://www.websitepulse.com/

聽兲甴掵 2024-08-10 06:45:56

您检查过 web.config 中的 debug=false 吗?

服务器是64位的吗?
尝试为您的应用程序创建专用的应用程序池,并将应用程序池设置为在 32 位经典模式下运行。
这有什么区别吗?

您的类是预编译的还是将其设置为在运行时编译?

Have you checked that the debug=false in your web.config?

Is the server 64bit?
Try to create a dedicated application pool for your application and set the application pool to run in 32bit classic mode.
Makes that any difference?

Is you class pre-compiled or have you set it up to compile at runtime?

蝶舞 2024-08-10 06:45:56

在页面中设置 Trace="true" (<%@ Page Trace="true"...),当页面加载到浏览器中时,您将在页面底部获得大量有用的信息。您将确切地知道服务器上处理请求需要多少时间。如果时间足够短,则问题可能出在 IIS 设置中。将它们与您的开发环境中的进行比较。

Set Trace="true" (<%@ Page Trace="true"...) in your page and you will get a lot of useful information at the bottom of the page when it loads in the browser. You will know exactly how much time is needed to process the request on the server. If the time is low enough, then the problem could be in the IIS settings. Compare them to the ones on your dev environment.

温柔女人霸气范 2024-08-10 06:45:56

您的 SQL 服务器是否在生产环境中位于另一台服务器上,但在开发环境中位于本地?

Is your SQL server on another server on production, but local on development?

念三年u 2024-08-10 06:45:56

阅读所有建议后,似乎没有任何效果,开始一点一点地从您的网站中取出代码,看看这如何影响时间。一次删除大约10行代码或HTML,看看是否有巨大的差异。

否则,它可能与 IIS 有关,抱歉,我不是 IIS 专家。

From reading all the suggestions, and it seemingly like nothing is working, start taking code out of your site, little by little, and see how that affects time. Remove about 10 lines of code or HTML at a time, and see if there is a huge difference.

Otherwise, it probably has to do with IIS, and sorry, I ain't no IIS guru.

幼儿园老大 2024-08-10 06:45:56

海量视图状态导致传输延迟?

Massive viewstate causing transmission delay?

笑梦风尘 2024-08-10 06:45:56

这是您服务器上唯一的网站吗? 16 GB 是相当不错的内存,但如果同一台服务器上有许多受欢迎的网站,它们可能会耗尽资源和 CPU 时间。

除此之外,我想不出您的网站生产速度比开发速度慢的任何原因。

你检查过索引吗?都在服务器上吗?

Is this the only website you have on the server? 16 GBs is pretty good memory, but if there are many popular websites on that same server they could be eating up the resources and CPU time.

Other than that I can't think of any reason why your website would be slow on production than in development.

Did you check out the indexes? They're all there on the server?

萌吟 2024-08-10 06:45:56

你需要减少变量。

尝试消除两个环境之间的所有差异,然后一一进行更改,直到弄清楚它是什么。

确保两个环境中的 web.config 相同。
确保两个环境都指向第三个机器上的同一数据库服务器。
确保两个环境中的 IIS 版本相同。
确保两个环境中的 IIS 配置相同。
在两个环境上运行相同的测试数据。
ETC...

You need to reduce the variables.

Try eliminating all of the differences between the two environments, then make changes one by one until you figure out what it is.

Make sure that the web.config is the same in both environments.
Make sure both environments point to the same database server on a 3rd box.
Make sure the same version of IIS is in both environments.
Make sure IIS is configured the same in both environments.
Run the same test data on both environments.
etc...

放手` 2024-08-10 06:45:56

在对我的开发机器和生产机器的性能差异进行了很长时间的头撞墙之后,我终于屈服于我内心深处的感觉,即处理器实际上比你想象的更重要思考。

我从基于 AMD 的解决方案更改为基于 Intel 的解决方案(Xeon!),获得了 0.3GHz 和更快的磁盘。

我还获得了性能提升,不再像我的开发机器那样慢 3 倍,而是现在降低到 0.75 倍左右 - 显然仍然不是我的开发机器能够达到的闪电速度,但它已经越来越接近了。

在进一步调试时,我注意到大部分性能消耗(这并不奇怪)来自必须编译查询的 LINQ to SQL,对我来说奇怪的是,一旦我尝试预编译 LINQ 查询并在我的两台机器,开发机器都更快。

After banging my head against the wall for a long time concerning the performance difference of my development machine and the production machine, I finally caved in to the feeling I've been having deep down that the processor actually matter a lot more than you'd think.

I changed from an AMD based solution to an Intel based solution (Xeon!), gaining .3GHz and faster disks.

I also gained a performance boost, instead of being x3 as slow as my development machine it's now down to something like x0.75 slower - obviously still not the lightning speeds that my development machine is capable of but it's getting closer.

While debugging this further I noticed that most of the performance hog (which is no surprise really) is coming from LINQ to SQL having to compile queries, what seems odd to me is that once I tried precompiling a LINQ query and running the same thing on both my machines, the development machine turned out to be faster.

注定孤独终老 2024-08-10 06:45:56

如果您已经研究了所有可能的代码优化但仍然面临性能问题,这可能是原因:

检查您的 Web.config 并删除以下内容。

 <system.codedom>
<compilers>
  <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers></system.codedom>

如果您进行预编译并且仅在网络服务器上使用已编译的程序集,则可以安全地从 web.config 中删除这些内容。

If you have already looked into all the possible code optimzation and still facing performance issues this could be the reason:

Check your Web.config and remove the following.

 <system.codedom>
<compilers>
  <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers></system.codedom>

These can be safely removed from the web.config if you do pre-compilation and only use the compiled assemblies on the webserver.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文