Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multithreading in Cold Fusion 2

Status
Not open for further replies.

jl8789

MIS
May 22, 2003
293
US
Is multithreading achievable in Cold Fusion? I have a page that does many tasks and is taking over 30 seconds to complete as one request on the server. A few of the tasks are sending out emails. I'd like to kick off the emailing as another process while continuing on to with the others. Is this possible, and if so how?

Thanks!
 
MX7 enterprise has "Asynchronous Processing" you might want to look into that.

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
did you check this option under CF Admin?

Limit simultaneous requests to
Restricts the number of simultaneously processed requests. Use this setting to increase overall system performance for heavy load applications. Requests beyond the specified limit are queued. You must restart the ColdFusion Application Server to enable this setting.
 
Falconseye, If he is running one script that does a lot of work, that is one request, regardless of the server setting.

The cfadmin setting allows multiple requests to be proccessed at the same time.


 
Yes, that is correct. I tried increasing the number and nothing happened.
 
could you please define ' I have a page that does many tasks ' in a little bit more detail? what are these tasks?
 
in other words CF processes top down, one instruction at a time. I believe jl8789 means to start a process, move to the next process before the first process is finished. As far as I know that is new to the enterprise version of MX7.

you COULD open a new browser to start a process while the other is running but probably not what you're aiming for.

multiple requests and multiple instructions per request are two different animals.

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Would CFFLUSH work in this senario? Or is this good for pushing page content only?
 
no. Cfflush is only for forcing data to the browser before it's finished. The process still has to end before it'll move to the next one.

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Multithreading in CFMX is definitely achievable. If you are using MX7.0 then you should look into "Asynchronous Processing" like cannedRadio suggested.

However if you are using MX 6.0 or 6.1 then you could use <cfhttp> to 'thread' your process and speed things up. By using HTTP status codes you can return a response to your calling template before the processing is complete, allowing it to be handled 'behind' the scenes. The only problem with using this approach is that you won't know if one of your threads successfully completed during that same page request. You will more than likely want to keep a record of the 'success' of each thread in db or log file.

Here is an example how you would implement 'threading' using cfhttp:

Create a template to perform the processing:
Code:
<b>Start process</b>

<cfhttp url="thread1.cfm" resolveURL="No" >
<cfhttp url="thread2.cfm" resolveURL="No" >
<cfhttp url="thread3.cfm" resolveURL="No" >

Create the threads that will perform the actions
Code:
<!--- thread1.cfm --->
<!--- Return an OK response to the cfhttp agent --->
<cfheader status="204" />

<!--- perform some processing --->
 ...

Here are some good articles on performing asyncronous events with CF:

HTTP Status Codes: Do the Unthinkable
Implement threading using CFML

Using the CFML event gateway for asynchronous CFCs


jalpino
 
hey, good post.

If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top