Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

When/how many threads are created in DCOM

Posted on 1998-09-10
Last Modified: 2013-12-03

We know there are different threading model when we create a DCOM server, like single apartment thread, multiple apartment thread and free thread.
Can some body tell me exactly at which point the thread is created ? And how many thread will be created in case there are many clients(say 100 clients) try to talk to a DCOM server ?



Question by:mikechen
  • 3
  • 2
LVL 13

Accepted Solution

Mirkwood earned 200 total points
ID: 1414355
When you are an out-of-process DCOM server (EXE), you dominate the threads. That is, when you don't create any new threads. Nobody will.
When you are in-process DCOM server (DLL), you are requested to follow at least the caller threading model. So if the caller is Apartment threading, you need to be apartment, mental or free threading. Single threading will give an error on CoInitialize. The other way around when you are apartment threading then the host may only be apartment or single threading. In this case a connection by a mental or free-threading host is not allowed.

Threads are only created by the main process.  No threads are created spontaniously. So if 100 clients each have 1 thread an call a dll then you have 100 processes with each 1 thread so your dll is called from 100 different threads. If you have an exe server, all calls will be serialed and you will only be called from within one thread, your thread.

The problem begins when using a tool like MFC or VB. In VB it can be specified that every window has it own thread with a maximum of a certain number that can be specified. In MFC, you can create your own thread. Classes can inhered from CWinThread and create a new thread. But all this is only important when you have an inprocess server. An outofprocess executable manages its own threads.

Author Comment

ID: 1414356
Hi, Mirkwood,

Thank you for your response.

Let's stick with out-proc server(.exe or service). From what I understand, when a DCOM client calls a method exposed by the server, the server itself will create a thread) to handle this request(or a thread from thread pool will do that). My question is when, how may threads are created in the server to handle these request when you have a lot of clients ?
And do we have any control on that ?



LVL 13

Expert Comment

ID: 1414357
Oh, you mean how many threads are created by the RPCss.
I've read that in Professional DCOM by Richard Grimes (page 182)

The threads created on the server's behalf have been created by DCOM out of a pool of threads that it maintains.In this situations, the server uses up to 6 threads (10 clients). There's no way for the system administrator to change this. However DCOM has been built with flexibility and scalibility in mind: if the server is heavily used, DCOM with dynamically create more threads to handle the requests and make the clients more responsive.

A utility like Pview can show you how many threads are created to handle the calls.

Author Comment

ID: 1414358
Hi, Mirkwood,

Is there any difference between STA and MTA regarding to how may threads are created ?

If the server is using STA, when there are many clients try to call the same method, exactly what happens ?



LVL 13

Expert Comment

ID: 1414359
Hmm, I've not really tested the difference. My quess would be that it does not make any difference since the RPC manager just manages the connections and the number of connections is equal given a certain number of users.
BTW: you can always mail Richard himself at rtg@grimes.demon.co.uk or visit his website http://www.grimes.demon.co.uk/

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Enable Clear Text in Win 8.1 7 46
Mixed results 10 90
Problem to file 3 83
Using MS Code on my Mac 6 68
This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question