Recall that scalability refers to the ease with which a solution can be transferred to a more
demanding environment than the environment for which you originally intended it. Scalability
issues typically have to do with transferring the application from desktop to enterprise, or
adding more users or other clients to the application's environment.
Following are several considerations for COM component scalability.
-
Classes in out-of-process components may have their Instancing property set to SingleUse.
SingleUse will guarantee that each object instantiated from the class will run in its
own address space. As the number of connections to a particular COM component on a system
rises, this will eliminate contention between different clients for a component, because
there will only be one object per client.
Of course, the trade-off for SingleUse instancing is that more server resources will be required
to instantiate each new copy of the object every time that a client requests a copy of
the object.
-
The different threading choices discussed in "Managing Threading
in Out-of-Process Components" can have an impact on scalability for out-of-process
servers.
Multithreading shows the best advantage when there are either multiple physical processors
on the server, or when the processes that clients are likely to request from a component
will be of uneven length and will be blocked most of the time (that is, they will wait
on file I/O or communications port activity).
In general, there is less advantage to a multithreaded COM component solution when there is only
one physical processor on the system and the component's object processes are all
of relatively equal length and do not block system resources for very long with activities
such as file access or communications. This is because such a scenario will cause about
the same amount of work for the single processor either way (multi- or single-threaded), with
the added disadvantage for multithreading that the server must add more overhead for
each thread.
As a rule of thumb, you will get the best performance out of a COM component if you choose options that
will guarantee close to one active thread per physical processor. This does not mean only one
thread running for the entire component, but rather one active thread. If three threads are running
at the moment, for example, but two of them are blocked waiting on file I/O, there is only one
active thread.
On single-CPU systems, therefore, you will see that you will need to do some
investigation and testing to determine whether multithreading is desirable. For
best scalability, choose round-robin threading with a low number of threads. Single-use
instancing can also be a good choice for scalability, as long as you know that
you have a powerful server.