RTC Forums

Subscription => Support => Topic started by: gs@cestronics on November 15, 2017, 12:32:34 PM



Title: MultiThreaded = Threaded Calls in one connection?
Post by: gs@cestronics on November 15, 2017, 12:32:34 PM
Hello,

I have a questsion about MultiThreading.

When the RtcHttpClient's MultiThreaded property is set to true,
does this setting only have an effect to the number of active connections at the same time, because they will be threaded
or is there also an effect to the Calls, called from a RtcClientModule, triggered by the same connection?

Means, when there is a connection, sending several Calls from a RtcClientModule, will this Calls be processed serial on the server side
or will they be processed parallel in different threads?

Thank you very much.


Title: Re: MultiThreaded = Threaded Calls in one connection?
Post by: D.Tkalcec (RTC) on November 15, 2017, 01:20:08 PM
A single TRtcHttpClient component represents a single connection to the Server, regardless of the MultiThreaded property. All requests posted through any component linked to the same TRtcHttpClient component will be placed in a request queue managed by that TRtcHttpClient component and sent out sequentially, in the order in which they were posted.

But, there is no guarantee that all requests posted to the Server from a single TRtcHttpClient component will be received through the same TCP/IP connection, because of Proxy Servers, Load Balancers, or anything else that might be used between your Clients and your Server. There is also a possibility that a connection will be closed before the Server receives a complete request and/or has a chance to send out a complete response. Due to the asynchronous nature of TCP/IP connections, if a Client opens a new connection after a connection problem and posts a new request (which is the usual scenario), it is also possible that more than one request will be "in processing" on the Server from the same Client at the same time (each in a different thread when the Server is running with MultiThreaded=TRUE).

PS. When you set MultiThreaded=TRUE on a TRtcHttpClient component, events triggered on that TRtcHttpClient, as well as any events triggered on a component linked to that TRtcHttClient component, will be executed in a background thread, unless you also set AutoSyncEvents=TRUE on the component responsible for posting and processing requests (like TRtcClientModule), in which case events on that specific component will be executed from the Main Thread (the component will be using the Sync method on all its events to achieve that).

Best Regards,
Danijel Tkalcec