One win service developed by C# and based on SQL Server.
I created a SqlConnection
and then do ExecuteReader
, but I face a problem when there is a high concurrent access.
On my local machine, code as below, average is 1.2s for one execution. MyObject
table has 40 columns and 400'000 rows.
for (int i = 0; i < 500; i++)
{
Task.Factory.StartNew(() =>
{
Stopwatch sw = new Stopwatch();
sw.Start();
var serialNumber = "55292572";
var orderIdArr = ORM.GetObjecys<MyObject>(t =>t.PrimaryId== Id).ToList();//Only Open connection, do SqlCommandExecute, close connection here
//sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
});
}
I deployed this service to 2 win server. You can guess I have 500 customers and they access this service very often.
Online environment, for one execution will cost 10s.
So I don't know why does this low performance happen? On my local machine, it only takes 1.2s.
Could anybody give me some answers or give my some improvable suggestions?
Many thanks!