Solved

When/how many threads are created in DCOM

Posted on 1998-09-10
5
184 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

19 Experts available now in Live!

Get 1:1 Help Now