Parallel Task Library and External SQL Server

I have a Windows service that performs a large number of tasks in parallel using a parallel task library (TPL). This should be expanded to handle tasks that interact with SQL Server on an external server.

It is assumed that TPL measures load well and assigns the correct number of parallel threads for tasks. Is there a way to find out about loading an external instance of SQL Server? The actual code for each task on the local server is quite small, but calls to the database can be quite heavy.

Perhaps I will not return to the fact that my service is clogging the database with a request because TPL sees that free resources are loaded on the local server or is there a known way to handle this?

+3
source share
3 answers

There is nothing in TPL that will help you with this. TPL is the control / maximization of the processor load of your local application. He does not know about loading SQL, not to mention another machine.

However, if you want to go crazy, there is an extension point called TaskScheduler. Theoretically, you can implement a customTaskScheduler one that can monitor the load on the SQL server and only perform scheduled tasks if the load is at a certain threshold level.

, , . , SQL, , , TPL . , , SQL- , , , . SQL Server .

+3

, , SQL Server.

0

TPL parses your data well, as it is a task for your OS to measure the load to determine (and actually is pretty good). Therefore, it is more a matter of configuration, but a matter of development. (Does your instance of SQL Server have higher priority than your service?).

-1
source

All Articles