another unrelated coldbox question.

sorry to post another question that doesn’t relate to coldbox directly but I don’t know anywhere to ask it to get a good answer so if you have places to ask coldfusion specific questions, let me know.

My question: Does anyone know how to get the number of running threads & queue threads created by using cfthread?

I have written a small coldbox app that is initiated by cron every minute. The coldbox handler creates multiple cfthreads to download specific content from thousands of locations. Think of it like a Google Bot of sorts. The problem I am running into is that the cfthreads get out of hand after a few hours of running and I have to restart my coldfusion instance.

The reason that the threads are getting out of control is that some sites take longer to download than others. I set everything to a two second timeout however I ‘feel’ like the timeout isn’t always timing out.

I was able to improve things by ‘joining’ all the threads and setting a total thread timeout of 60 seconds at the end of each cron job execution hitting the coldbox handler.

a couple side notes - if I lower the number of threads being created each cron job, it only takes longer before the server crashes.

If I could access the total number of running threads & queued threads, I can have my coldbox handler throttle the number of created threads on each execution.

Any ideas?


Jeremy R. DeYoung
Phone: 615.261.8201

FacebookLinkedInGoogle ReaderTwitterAmazonGoogle
Google Talk/LunarFly Skype/DeYoungJD

Are you on Adobe CF? You could use the server monitor. Otherwise, you may want to give FusionReactor a try.# http://www.fusion-reactor.com/fr/# Curt Gratz

Curt,

Yes i’m using Adobe CF9 and I can easily see the number of threads using the monitor. However, I need my code to be able to read the number of queued and running threads.


Jeremy R. DeYoung
Phone: 615.261.8201

FacebookLinkedInGoogle ReaderTwitterAmazonGoogle
Google Talk/LunarFly Skype/DeYoungJD

As a cross-engine way of doing this, I implemented a thread-pool like construct with an CB interceptor. You’d announce the interception point as a way to run a new event asynchronously and then in the interceptor it would keep track of the currently running threads (using an application scoped variable) and queue the newly dispatched request if there are no free threads in the pool.

There is probably a way to dig down into the guts of CF to keep track of the running threads, though I’m not sure if it is supported or not. There is also an actual threadpool java construct that could handle this sort of situation (if I understand it correctly) but I haven’t had the time to look into it too deeply.

Hope that helps,
Judah