基于IIS的asp.net webapi性能非常慢,如何提高?
测试过程:打开200个winform的exe后,采用某种措施,使它们几乎同时对IIS进行访问调用webapi,结果执行完这200个调用总共耗时16秒, 所以我觉得性能非常低,代码如下,请问如何提高(IIS服务器为一般的个人机器 4核4GB)
api代码如下:
[HttpPost]
[ActionName("post2")]
public string post2()
{
SqlConnection con246 = new SqlConnection("server=10.10.7.70;uid=sa;database=wy;pwd=sa;Min Pool Size=1;Max Pool Size=100;");
con246.Open();
SqlCommand cmd246 = con246.CreateCommand();
cmd246.CommandText = "insert insert_table values(getdate(),getdate())";
cmd246.ExecuteNonQuery();
con246.Close();
return "ok";
}
c#客户端代码如下:
string url = "http://localhost:19159//api/user/post2";
HttpClient client = new HttpClient();
this.richTextBox1.Text = client.PostAsync(url, null).Result.Content.ReadAsStringAsync().Result;