Solved

When/how many threads are created in DCOM

Posted on 1998-09-10
5
185 Views
Last Modified: 2013-12-03
Hi,

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 ?


Thanks,


Mike


0
Comment
Question by:mikechen
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
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.
0
 

Author Comment

by:mikechen
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 ?

Thanks,

Mike

0
 
LVL 13

Expert Comment

by:Mirkwood
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.
0
 

Author Comment

by:mikechen
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 ?

Thanks,


Mike


0
 
LVL 13

Expert Comment

by:Mirkwood
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/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now