我使用压力测试工具,用C#编写
许多任务并行运行,标准结果为每秒40-50次请求。 但是当我打开Fiddler时 - 请求增长到~300-500并且服务器处理它。
noFiddler变体的瓶颈在哪里?
简单任务
public class PersonListTask : LTask
{
public override string Path => "/person/list?query={page: 1, pageSize: 30}";
public override string Method => "GET";
public override async Task ProcessAsync(IUserContext context)
{
var request = CreateRequestForContext(context); //WebRequest
var response = await request.GetResponseAsync();
if (response == null)
throw new Exception("Responce null");
var responceStream = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
responceStream.ReadToEnd();
Interlocked.Increment(ref RequestCount);
}
}
..........
..........
//running
private async Task Task_Function(IUserContext context)
{
while (true)
{
await Task.WhenAll(LTaskCollection.Tasks.Select(x => x.ProcessAsync(context)));
}
}