Quarantine SQL Server queries in .net 3.5
Alright, we have two database servers, one is owned by us, one owned by a partner. Our partners have been having issues lately that have been causing us numerous sql timeout errors, which takes down our whole system. We'd prefer to limit the time those queries can take to say 20 seconds max, otherwise quit 开发者_如何学Gotrying and throw the error (which we can catch with a try/catch block).
Couple of questions:
- Is there a way to set a particular db/connection string to timeout after X seconds?
- Is this the best way to quarantine that other system? or are there better ways to go about this?
Thanks
Dumb question - commandTimeout in the connection string will suffice for my needs.
These kind of issues are best addressed by the SQL Server Resource Governor. Resource Governor will limit the amount of memory and CPU a workload can consume. You can split the server into two workloads and allocate 50% to each, so that you and your partner can each consume 50% of the server resources. This is much better than setting a CommandTimeout
(which has to be set individually for each SqlCommand, setting it on a connection string has no effect) because the command timeout will not only affect both parties (ie. the one abusing the resources and the victim) but is also too late: the commandTimeout will only react after the server is slow. Besides, a party cans till abuse resources with frequent small commands.
精彩评论