Board index » delphi » Ideal Remote data module configuration with ADO?

Ideal Remote data module configuration with ADO?


Does anyone has a recommendation on how to set the instancing and threading
model for a remote data module when using ADO?

The defaults are Multiple Instances and Apartment, but I was reading that
'Apartment' is mainly used for BDE access and for ADO 'Free' or 'Both' would
be the threading mode of choice. If using 'Free' or 'Both' do I need to
manually take care of threading or does ADO handle it?

Thanks a million in advance!
Johannes Lindthaler


Re:Ideal Remote data module configuration with ADO?

Not sure if this is what you want but it may help.

3.2 Use ADO like an Apartment model

Though the ADO implementation is free-threaded, dont use it in that way in
the middle tier. Dont cache an instance of an ADO object, say Connection,
globally and invoke methods on it concurrently from multiple threads. If
each client request in your application model invokes the
Connection::Execute method on a globally cached Connection object on the
middle tier, your application will not scale. This is because of
synchronization in the Connection::Execute method.

You will get much better throughput by using an application model where each
client request creates a new instance of a Connection object, calls
Connection::Open, Connection::Execute, and releases the Connection object on
the middle tier. Each request does have the additional overhead of creating
a new instance of a Connection object and obtaining a connection from the
connection pool. However, because your Connection::Execute call isnt
synchronized, the throughput is much better.

3.3 Use ADO marked as Apartment model when using it like an Apartment model

ADO 2.0 includes some optimizations when marked as an Apartment model. It
determines the threading model from the registry at DLL load time. If the
threading model is Apartment, only the class factories and globals are
protected with critical sections. At all other places in code, ADO doesnt
initialize, delete, enter, or leave critical sections. This leads to a
significant improvement in the scaling characteristic of ADO applications.
The default threading model of ADO 2.0 is Apartment, as in ADO 1.0 and 1.5,
so you dont have to do anything to take advantage of this optimization
other than use ADO like an Apartment model.

Other Threads