Solved

When/how many threads are created in DCOM

Posted on 1998-09-10
5
193 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
[X]
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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

734 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