0

I have a scheduled task that creates 20 to 50 or so threads. I have ColdFusion set to run 20 concurrently, but I am getting push back from the DB people saying that I am hitting their DB too hard.

I am wondering if there is a way to have the page limit the thread count to 5 concurrent running threads. Or do something so that I don't have to alter the global setting

Fragment of code:

<cfoutput query="qrySetup">
  <p>Starting thread for #Info#</p>


   <cfset sleep(30)><!--- vain attempt at throdding --->


  <cfthread name="t#currentrow#"
     stConf = qrySetup.Conf     
     >

 ...

   <CFSTOREDPROC PROCEDURE="usp_Big_and_slow">
        <CFPROCPARAM VALUE="#stConf#"                   CFSQLTYPE="cf_sql_varchar">

        <cfprocresult name="local.qryResult" resultSet = "1">
    </CFSTOREDPROC>

 ...


  </cfthread>
</cfoutput>
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • I have a hard time imagining a scheduled task that would need 50 threads. What problem are you solving? Also, what's the use of 50 threads if you have only, say, 4 or 8 CPU cores? Sounds like you have to re-think your approach. – Tomalak Oct 24 '14 at 17:21
  • The server I am running this against has 24 processors. Each one of the tasks takes between 30 seconds and 30 minutes to run. – James A Mohler Oct 24 '14 at 17:24
  • In terms of limiting the thread count to 5, please show how you are generating the 20-50 threads now. – Dan Bracuk Oct 24 '14 at 17:38
  • @JamesAMohler 50 threads is a very large number James. I would do a rethink. If you are doing some huge import task, consider another way to do - another platform. Web application platforms (although commonly used for such things) are really best at thousands of small requests that begin and end in a matter of milliseconds. They are not great at heavy workload tasks. – Mark A Kruger Oct 24 '14 at 17:46
  • FYI - why can you not simply limit this in your scheduled task code? – Mark A Kruger Oct 24 '14 at 17:47
  • 1
    That appears to be what he is requesting assistance with. – Dan Bracuk Oct 24 '14 at 18:09
  • That seems more like coding choice than a specific problem. Count, and when the number reaches 5, don't create any more - and set something up to handle the queue. yes? – Mark A Kruger Oct 24 '14 at 18:10
  • Hard to tell until he shows the code I requested earlier. – Dan Bracuk Oct 24 '14 at 18:53

0 Answers0