Multi-threading Indy IdHTTP requests. Performance consideration issues

785 Views Asked by At

My application queries 7 marketplaces in a row using Indy HTTP client. All marketplaces provide a unified interface to request/response. That said, the structure of request/response is the same for all 7 marketplaces.

I submit GTIN to a MainForm's TEdit box and the app posts 7 RESTful requests to the marketplaces and returns XML responses for all of them.

My idea is to wrap each request in a separate thread, but I am really concerned by the performance issues. Normaly I perform 1 request in 3-5 seconds.

Each thread is created in a for statement and initalizes TIdHTTP object, makes a request, gets an XML-response, parses it and ships it back to the MainForm.

When the job is done each thread needs to be terminated (or paused?) If the thread completely terminates, then it must perform the same initialization routine on a next request. I find it relatively slow, assuming 7 thread initializations at a time.

However, if the thread is paused it merely resides in memory, has all its factories initialized and is ready to accept next requests.

How do I leave the thread operationally terminated, but still completely initialized? I assume, if TIdHTTP and XML-parsing objects stay alive in a paused thead, they will act much faster on the next request. Does it have any sense?

0

There are 0 best solutions below