- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个基于 JSON 和 POST 方法的 WCF Web 服务,它有一个名为网站的功能。这个函数有一个简单的代码,只使用下面的代码调用另一个网络服务:
using (var cli = new MyWebClient())
{
Task<string> t = cli.UploadStringTaskAsync(myURI, "POST", request);
if (t == await Task.WhenAny(t, Task.Delay(400)))
{
response = t.Result;
}
else
{
response = "";
}
cli.Dispose();
}
和MyWebClient
类实现为:
class MyWebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest request = base.GetWebRequest(address);
if (request is HttpWebRequest)
{
(request as HttpWebRequest).KeepAlive = true;
(request as HttpWebRequest).ContentType = "application/json";
}
return request;
}
}
问题是我可以在 IIS 中看到大量请求保持打开状态超过 18 秒,对于我的 1 或 2 个工作进程甚至更多(如您在其中一个的附图中所见)! !!这使得服务速度非常慢。请注意,此服务每秒大约有 2K 个请求,此服务的应用程序池有一个包含 12 个工作进程的网络花园,队列限制为 10K。当有(例如)4 个工作进程在可预测的时间(大约 450 毫秒)内工作并且 IIS 显示其请求的最大运行时间约为 380 时,就会发生这种情况。
a large number of requests that remain open in the IIS
请注意,我使用了 cli.UploadStringTaskAsync
,因此 cli
不考虑超时。因此,我必须实现类似 t == await Task.WhenAny(t, Task.Delay(400))
的代码来模拟超时。
你觉得有什么问题?!使用 await
是否会导致多次上下文切换并且请求排队等待 cpu 执行?
编辑:
Here您可以找到一些有用的建议,但没有人可以帮助解决问题。我在我的应用程序的网络配置中设置了它们,但它无法解决我的问题。
更新:
作为附加信息注意网卡是1G的,我们最多有100Mgb/s的带宽使用。 Intel Xeon E5-1650 V3 3.5 Ghz 有 6 个核心和 12 个逻辑处理器。我们有 128GB RAM 和 480GB SSD。
最佳答案
我找到了解决问题的方法。关键点是“processModel 元素(ASP.NET 设置架构)”。正如我在问题中提到的:
This situation takes place when there are (for example) 4 worker processes working in a predictable time(about 450 ms) and IIS shows that the maximum elapsed time on their requests are about 380.
所以,我认为平衡工作进程之间的负载可能是个问题。通过手动配置 processModel 元素,我已经解决了这个问题。经过大量研究后,我发现 this关于 processModel 元素及其属性的有值(value)的链接。
还有 this链接描述了每个项目的所有属性和效果。正如此链接中提到的,有 2 个重要属性称为“requestLimit”和“requestQueueLimit”:
requestQueueLimit: Specifies the number of requests that are allowed in the queue before ASP.NET begins returning the message "503 – Server Too Busy" to new requests. The default is 5000.
requestLimit: Specifies the number of requests that are allowed before ASP.NET automatically launches a new worker process to take the place of the current one. The default is Infinite.
解决方案 是通过一个有理数来控制和限制 requestLimit,例如在我的例子中是 300。此外,通过将工作进程数与 requestLimit 相乘来限制 requestQueueLimit。我已经将worker进程的数量增加到20个,通过这个配置总共可以排队6000个请求,每个worker进程最多有300个请求。通过达到每个工作进程 300 个请求,ASP.NET 会自动启动一个新的工作进程来取代当前的工作进程。
因此负载在工作进程之间得到更好的平衡。我检查了所有队列,没有超过 400 时间的请求!!!
我认为通过使用这些属性(requestLimit、requestQueueLimit 和number,此解决方案可以用作 IIS 和工作进程的半负载平衡器算法工作进程数 ).
关于c# - IIS 中托管的 WCF 有很多打开的请求,服务速度变慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41088393/
我在想出一个算法时遇到了麻烦... 我有一系列 GPS 数据,以 1 秒为间隔记录时间、速度、距离。假设距离是米,速度是米/秒。可能有超过 2 小时的数据,或 7200 个点。这里的“时间”字段主要是
使用java排序器,即: Collections.sort(myArrayList, new Comparator() { @Override public int c
有什么区别吗 SELECT * FROM my_table 和 SELECT my_column_id FROM my_table 地点: my_table 有百万行 网站上有大量并发用户进行sql查
有2个样本。 在第一个示例中,使用 orderby 可以更快地获得结果。 (根据 phpmyadmin 速度报告) 在另一个例子中,我没有使用 order by,它给出的结果较慢。 (根据 phpmy
我注意到,如果我将训练数据加载到内存中并将其作为 numpy 数组提供到图中,与使用相同大小的 shuffle 批次相比,速度会有很大差异,我的数据有大约 1000 个实例。 使用内存 1000 次迭
我在 python 中使用破折号。我正在绘制记录到 SQLite 数据库中的实时数据,目前,我正在绘制单个值与时间线图。我计划再添加 20 个图表,但目前,随着时间的增加, plotly 变慢,我认为
我试图调用 hasNext Velocity 模板中的方法,以便根据 foreach 循环中的位置影响行为 - 仅 hasNext没有按照文档工作。 这是 Velocity 用户指南的片段,关于 ha
在我正在制作的游戏中,我有两个点,pt1 和 pt2,我想计算出它们之间的角度。我已经在较早的计算中计算出距离。显而易见的方法是对垂直距离上的水平距离进行反正切 (tan(theta) = opp/a
我经常遇到字符串值不存在和/或为空的情况。这是测试这种情况的最佳方法吗? #if( $incentive.disclaimer && $!incentive.disclaimer != '' )
我想将一个模板nested包含在其他模板cont1,cont2和cont3中。 并且嵌套模板应仅对cont1隐藏一个特定控件。 在包含在cont1中之前,我想为一些标志变量$hideMyControl
是否可以更改从“Windows Azure Media Encoder”输出的音频的播放速度? 我正在使用配置为“WMA High Quality Audio”的“Windows Azure Medi
我使用速度将String(template)与字段合并 hi there I'am ${name}, And I'am ${age} old. velocity将字段${name}和${age}与一种
我使用的是 LockedBitmap 类,它简化了 C# 中位图数据的处理。目前它正在将数据复制到本地 byte[] 数组中,然后通过其类方法访问该数组以获取/设置像素颜色值。 这比直接通过指针访问锁
我尝试在 VM_global_library.vm 文件中添加一堆 #set($x=abc) 语句,但这些变量在我的 VM 模板中不可用。 我想为图像的基本路径等设置一个全局变量。这可能吗? 最佳答案
我的项目结构: -src --main ---java ----makers -----SomeClass ---resources ----htmlPattern.vm 如何告诉 SomeClass
我正在尝试从 Velocity 中的字符串中删除不需要的字符(换行符可以,但不能像 EM 和 CAN ASCII 控制字符那样)。 #set($cleanScreen = $cleanScreen.r
我想在日.月.年之间的点处分割日期。例如:2015 年 1 月 14 日至 {14, 01, 2015}这是我使用的代码:dates3.get(0) 包含我从页面的文本字段获取的字符串“14.01.2
之后,从 1.5 升级到速度引擎 1.7 出现了 1.5 没有的问题。为了解释这个问题,我必须展示一个代码片段: #foreach($someVariable in $someCollection)
我想知道从表中选择所有字段是否更快: SELECT * 或只选择您真正需要的: SELECT field1, field2, field3, field4, field5... 假设表有大约 10 个
我正在尝试模仿照片应用程序的行为,在该应用程序中,用户用手指平移照片并且照片具有一定的速度。由于我不会深入的原因,我不能将 UIScrollView 与它的缩放 UIImageView 一起使用,而是
我是一名优秀的程序员,十分优秀!