对数据库调用的w3wp.exe高网络 [英] w3wp.exe high network on database call

查看:291
本文介绍了对数据库调用的w3wp.exe高网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到,我还没有见过一个相当独特的问题。

客户有一个应用服务器和数据库服务器。应用服务器(WIN 2008)运行ASP.NET MVC 3应用程序。数据库服务器(也赢得2008)上运行的SQL Server 2008。

每当到数据库的请求时,CPU进行的w3wp.exe上升到50% - 80%和网络流量达到2%(10 Gbps)的。这需要一分钟左右之后其上显示所请求的网页。

我查了LINQ的实际执行时间,只需要几毫秒来获得数据。

我希望有专业人士可以在这里阐明这是怎么回事的一些情况。当然,它的作品在我的机器上。

更新

检索828行从SQL Server Management Studio中(应用服务器)执行

即使查询需要整整12秒才能完成......所以我想这个问题是不是应用程序,但在某个数据库服务器或连接上

更新2
下面是一些有趣的事情,我发现了。

这是缓慢的code:

  MyAppDataContext的DataContext = MyAppDataContext.CreateNewContext();
IEnumerable的<请求和GT;实体= DataContext.Requests;使用(profiler.Step(获取数据)){
    IEnumerable的<请求和GT;数据=从实体点¯x
                                    其中,x.ControleStatus == 4
                                    排序依据x.ID
                                    选择X;
}

但是,当我改变了IEnumerable IQueryable的到,在code执行速度快10倍:

  MyAppDataContext的DataContext = MyAppDataContext.CreateNewContext();
IQueryable的<请求和GT;实体= DataContext.Requests.AsQueryable();使用(profiler.Step(获取数据)){
    IQueryable的<请求和GT;数据=从实体点¯x
                                   其中,x.ControleStatus == 4
                                   排序依据x.ID
                                   选择X;
}

所以我的问题是:这可能是导致IEnumerable和IQueryable的之间的这种大的区别


解决方案

  

每当到数据库的请求时,CPU进行的w3wp.exe上升
  50 - 80%的网络流量到达(10 Gbps)的2%



  1. 您是否服用内存泄漏的照顾?

  2. using语句包含在数据库交互类?

  3. 我使用红门蚂蚁内存分析器来检查内存管理问题。

  4. 您正在寻找SQL事件探查器告诉持续时间

I've come across a rather unique problem that I haven't seen before.

The customer has a application server and a database server. The application server (win 2008) runs a ASP.NET MVC 3 App. The database server (also Win 2008) runs SQL Server 2008.

Whenever a request to the database is made, CPU for w3wp.exe goes up to 50 - 80 % and network traffic reaches 2% (of 10 Gbps). This takes a minute or so after which the requested web page is displayed.

I checked the actual Linq execution time and it only takes a few milliseconds to get the data.

I hope some of the professionals here can shed some light on what's going on. Of course, it works on my machine.

update

Even a query executed from SQL Server Management Studio (on the app server) that retrieves 828 rows takes a full 12 seconds to complete... So I guess the problem is not the app but somewhere on the database server or the connection

update 2 Here's something interesting I found out.

This is the slow code:

MyAppDataContext DataContext = MyAppDataContext.CreateNewContext();
IEnumerable<Requests> Entities = DataContext.Requests;

using (profiler.Step("get data")) {
    IEnumerable<Requests> dataset = from x in Entities
                                    where x.ControleStatus == 4
                                    orderby x.ID
                                    select x;
}

But when I change IEnumerable to IQueryable, the code executes 10x faster:

MyAppDataContext DataContext = MyAppDataContext.CreateNewContext();
IQueryable<Requests> Entities = DataContext.Requests.AsQueryable();

using (profiler.Step("get data")) {
    IQueryable<Requests> dataset = from x in Entities
                                   where x.ControleStatus == 4
                                   orderby x.ID
                                   select x;
}

So my question is: what could be causing this big difference between IEnumerable and IQueryable ?

解决方案

Whenever a request to the database is made, CPU for w3wp.exe goes up to 50 - 80 % and network traffic reaches 2% (of 10 Gbps).

  1. Are you taking care of Memory leaks?
  2. Using statements are included in the Database Interaction classes?
  3. I use Red Gate ANTS Memory Profiler to check for the Memory Management Issues.
  4. You are looking for SQL Profiler that tells Reads and Duration.

这篇关于对数据库调用的w3wp.exe高网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆