woomla
2008-08-29 07:26:15 UTC
Hi all,
I have a HTTP server which needs to handle very much requests. I want
to use TIdSchedulerOfThreadPool to avoid having a Thread created for
every request. I experience some problems though. Without setting
IdHTTPServer->Scheduler to the ThreadPool, and thus using the default,
there are no problems. But then the app creates so many Threads (>50 /
sec). With reusing, I only need less then 10 threads. So I set the
PoolSize at 10 and MaxThreads at 50.
When I am in the middle of a IdHTTPServerCommandGet (the webpage
continuously loads jpegs), and I change to another webpage, the
connection (of the current request / Context) is closed. When trying
to WriteContent, I receive a ClosedGracefully Exception. WriteContent
Terminates the Thread (Yarn is Stopped and thus the Thread is
destroyed). This itself is no problem, as soon as there are no more
threads to handle a request, a new Thread (and TIdYarnOfThread) is
created and remains in the pool (for a maximum of 10).
But here comes the trouble. When this scenario happens, only the first
few requests are handled and the other requests are not handled
anymore. It seems to me that the thread that is being terminated is
still used to handle a request and thus freezes the handling of the
other request. But here my knowledge and debugging skills for Indy
stop. When this happens once, terminating the server will hang in
freeing the Threads (Yarns). It looks like the Thread is Suspended and
it never gets a resume. If I reload the webpage after a short while,
all requests are handled correctly.
The webpage in question has many jpegs, css's and javascripts so when
requesting the page, a lot of requests are done in short time. This
requesting and it's timing is handled by the browser (FireFox in this
case). When I use a proxy (i.e. Fiddler), which slightly delays the
request, Indy can handle the requests fine. This indicates to me a
timing (and possible locking) issue.
That's it, I hope I've made myself clear and someone can help me get
past this problem (should I write my own pool?) In the mean time, I
will continue to look into this problem and see if I can pinpoint the
problem more accurate. (But I have to work with C++Builder and cannot
compile Protocols for debug, it gives an internal compiler error,
though the rest compiles fine in debug).
Wim
I have a HTTP server which needs to handle very much requests. I want
to use TIdSchedulerOfThreadPool to avoid having a Thread created for
every request. I experience some problems though. Without setting
IdHTTPServer->Scheduler to the ThreadPool, and thus using the default,
there are no problems. But then the app creates so many Threads (>50 /
sec). With reusing, I only need less then 10 threads. So I set the
PoolSize at 10 and MaxThreads at 50.
When I am in the middle of a IdHTTPServerCommandGet (the webpage
continuously loads jpegs), and I change to another webpage, the
connection (of the current request / Context) is closed. When trying
to WriteContent, I receive a ClosedGracefully Exception. WriteContent
Terminates the Thread (Yarn is Stopped and thus the Thread is
destroyed). This itself is no problem, as soon as there are no more
threads to handle a request, a new Thread (and TIdYarnOfThread) is
created and remains in the pool (for a maximum of 10).
But here comes the trouble. When this scenario happens, only the first
few requests are handled and the other requests are not handled
anymore. It seems to me that the thread that is being terminated is
still used to handle a request and thus freezes the handling of the
other request. But here my knowledge and debugging skills for Indy
stop. When this happens once, terminating the server will hang in
freeing the Threads (Yarns). It looks like the Thread is Suspended and
it never gets a resume. If I reload the webpage after a short while,
all requests are handled correctly.
The webpage in question has many jpegs, css's and javascripts so when
requesting the page, a lot of requests are done in short time. This
requesting and it's timing is handled by the browser (FireFox in this
case). When I use a proxy (i.e. Fiddler), which slightly delays the
request, Indy can handle the requests fine. This indicates to me a
timing (and possible locking) issue.
That's it, I hope I've made myself clear and someone can help me get
past this problem (should I write my own pool?) In the mean time, I
will continue to look into this problem and see if I can pinpoint the
problem more accurate. (But I have to work with C++Builder and cannot
compile Protocols for debug, it gives an internal compiler error,
though the rest compiles fine in debug).
Wim