473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Singleton Problem

Hello,
We have an application which communicates using remoting. There is a server
which is a Windows Service. The server exposes an object which is a
singleton. The client is a Web Application which makes calls to the service.
We are using tcp channel which is using binaryformatter by default. The
problem is that after a certain number of remoting calls the calls dont get
through to the server. The client application makes the call and hangs up.
The call never reaches the service. The initial calls get through. Earlier we
used http channel. Then the problem was worse. The client could not make more
than 20 calls. Now it hangs up after about 100 or so calls if made
sucessively. We had come to conclusion that it is some threadpool issue as we
observed that after some time the thread count goes high. The observation in
case of both http and tcp was that if the thread count crosses a certain
limit, the server does not accept more calls. If the calls don't come
successively, ie with in a short amount of time, the service does accept
calls. I believe this is not a synchronization problem as we have use sync
objects to protect in remoting calls. Also another point in this favor is
that the same code hangs up earlier with http channel.
The configuration for remote server is
<system.runtime.remoting>
<application>
<service>
<wellknown mode="Singleton" displayName="*****"
type="***.***,Service.exe" objectUri="***.rem" />
</service>
<channels>
<channel ref="tcp" port="1978"></channel>
</channels>
</application>
</system.runtime.remoting>

// This is in the shared assembly
public __gc __interface IInterface
{
virtual System::String* Request(System::String* a_pRequest) = 0;
};

// This is in an assembly with the service
public __gc class CInterface : public IInterface, public
System::MarshalByRefObject
{
public:
// Singleton Pattern applied
virtual System::String* Request(System::String* a_pRequest) {
privateLock(); Process(); privateUnLock();
System::GC::Collect(); // After ading this we get to process more calls
return "****" };
virtual System::Object* InitializeLifetimeService() {return 0;};
void privateRegisterForRemoting()
{
try
{

System::Runtime::Remoting::RemotingConfiguration:: Configure(System::AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
System::Runtime::Remoting::RemotingServices::Marsh al(this, "***.rem");
}
catch(System::Exception* a_pException)
{
WRITETOSYSTEMLOG(a_pException);
}
};
What could be the problem and how can this be addressed? We strongly think
this is some threadpool issue. Or there may be some problem the way we use
remoting.
We can change it to singlecall if needed, but first we want to check the issue
Nov 17 '05 #1
8 1257
Sudesh,

The Request method calls privateLock, Process, and privateUnLock in
that order. One thing that jumps out at me is that you don't have the
Process method call wrapped in a try/catch/finally block. If an
unhandled exception is thrown in the Process method then the
privateUnLock method won't be called and all subsequent remoting calls
will be blocked indefinitely.

Brian

Sudesh Sawant wrote:
Hello,
We have an application which communicates using remoting. There is a server
which is a Windows Service. The server exposes an object which is a
singleton. The client is a Web Application which makes calls to the service.
We are using tcp channel which is using binaryformatter by default. The
problem is that after a certain number of remoting calls the calls dont get
through to the server. The client application makes the call and hangs up.
The call never reaches the service. The initial calls get through. Earlier we
used http channel. Then the problem was worse. The client could not make more
than 20 calls. Now it hangs up after about 100 or so calls if made
sucessively. We had come to conclusion that it is some threadpool issue as we
observed that after some time the thread count goes high. The observation in
case of both http and tcp was that if the thread count crosses a certain
limit, the server does not accept more calls. If the calls don't come
successively, ie with in a short amount of time, the service does accept
calls. I believe this is not a synchronization problem as we have use sync
objects to protect in remoting calls. Also another point in this favor is
that the same code hangs up earlier with http channel.
The configuration for remote server is
<system.runtime.remoting>
<application>
<service>
<wellknown mode="Singleton" displayName="*****"
type="***.***,Service.exe" objectUri="***.rem" />
</service>
<channels>
<channel ref="tcp" port="1978"></channel>
</channels>
</application>
</system.runtime.remoting>

// This is in the shared assembly
public __gc __interface IInterface
{
virtual System::String* Request(System::String* a_pRequest) = 0;
};

// This is in an assembly with the service
public __gc class CInterface : public IInterface, public
System::MarshalByRefObject
{
public:
// Singleton Pattern applied
virtual System::String* Request(System::String* a_pRequest) {
privateLock(); Process(); privateUnLock();
System::GC::Collect(); // After ading this we get to process more calls
return "****" };
virtual System::Object* InitializeLifetimeService() {return 0;};
void privateRegisterForRemoting()
{
try
{

System::Runtime::Remoting::RemotingConfiguration:: Configure(System::AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
System::Runtime::Remoting::RemotingServices::Marsh al(this, "***.rem");
}
catch(System::Exception* a_pException)
{
WRITETOSYSTEMLOG(a_pException);
}
};
What could be the problem and how can this be addressed? We strongly think
this is some threadpool issue. Or there may be some problem the way we use
remoting.
We can change it to singlecall if needed, but first we want to check the issue


Nov 17 '05 #2
Hi Brian,
Process is just a dummy function. The actual processing function has try
catch blocks.
My main problem is that after a certain number of remoting calls the calls
dont get through to the server. I had tied searching on the net for the
problem and found from a couple of sites that people where facing a similar
problem. We got improvements in performance when we changed the channel to
tcp, but still it doesnot suffice. The explanation given for this was that
the clr threadpool gets exhausted and cant fork more threads for more
requests. I had tried to check with my code if there are any leaks but then i
get the threadcount decreasing after the request has been completed, so there
may be no such leak. But somewhere the requests have piledup at lower level
and the pool gets exhausted
My last approach is to try singlecall.
Cheers,
Sudesh
"Brian Gideon" wrote:
Sudesh,

The Request method calls privateLock, Process, and privateUnLock in
that order. One thing that jumps out at me is that you don't have the
Process method call wrapped in a try/catch/finally block. If an
unhandled exception is thrown in the Process method then the
privateUnLock method won't be called and all subsequent remoting calls
will be blocked indefinitely.

Brian

Sudesh Sawant wrote:
Hello,
We have an application which communicates using remoting. There is a server
which is a Windows Service. The server exposes an object which is a
singleton. The client is a Web Application which makes calls to the service.
We are using tcp channel which is using binaryformatter by default. The
problem is that after a certain number of remoting calls the calls dont get
through to the server. The client application makes the call and hangs up.
The call never reaches the service. The initial calls get through. Earlier we
used http channel. Then the problem was worse. The client could not make more
than 20 calls. Now it hangs up after about 100 or so calls if made
sucessively. We had come to conclusion that it is some threadpool issue as we
observed that after some time the thread count goes high. The observation in
case of both http and tcp was that if the thread count crosses a certain
limit, the server does not accept more calls. If the calls don't come
successively, ie with in a short amount of time, the service does accept
calls. I believe this is not a synchronization problem as we have use sync
objects to protect in remoting calls. Also another point in this favor is
that the same code hangs up earlier with http channel.
The configuration for remote server is
<system.runtime.remoting>
<application>
<service>
<wellknown mode="Singleton" displayName="*****"
type="***.***,Service.exe" objectUri="***.rem" />
</service>
<channels>
<channel ref="tcp" port="1978"></channel>
</channels>
</application>
</system.runtime.remoting>

// This is in the shared assembly
public __gc __interface IInterface
{
virtual System::String* Request(System::String* a_pRequest) = 0;
};

// This is in an assembly with the service
public __gc class CInterface : public IInterface, public
System::MarshalByRefObject
{
public:
// Singleton Pattern applied
virtual System::String* Request(System::String* a_pRequest) {
privateLock(); Process(); privateUnLock();
System::GC::Collect(); // After ading this we get to process more calls
return "****" };
virtual System::Object* InitializeLifetimeService() {return 0;};
void privateRegisterForRemoting()
{
try
{

System::Runtime::Remoting::RemotingConfiguration:: Configure(System::AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
System::Runtime::Remoting::RemotingServices::Marsh al(this, "***.rem");
}
catch(System::Exception* a_pException)
{
WRITETOSYSTEMLOG(a_pException);
}
};
What could be the problem and how can this be addressed? We strongly think
this is some threadpool issue. Or there may be some problem the way we use
remoting.
We can change it to singlecall if needed, but first we want to check the issue


Nov 17 '05 #3
Have you attached a debbuger to the service when the call hangs? If so how
many threads are running on the service?

--
Jared Parsons [MSFT]
ja******@online.microsoft.com
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no rights"
"Sudesh Sawant" <Su**********@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
Hi Brian,
Process is just a dummy function. The actual processing function has try
catch blocks.
My main problem is that after a certain number of remoting calls the calls
dont get through to the server. I had tied searching on the net for the
problem and found from a couple of sites that people where facing a
similar
problem. We got improvements in performance when we changed the channel to
tcp, but still it doesnot suffice. The explanation given for this was that
the clr threadpool gets exhausted and cant fork more threads for more
requests. I had tried to check with my code if there are any leaks but
then i
get the threadcount decreasing after the request has been completed, so
there
may be no such leak. But somewhere the requests have piledup at lower
level
and the pool gets exhausted
My last approach is to try singlecall.
Cheers,
Sudesh
"Brian Gideon" wrote:
Sudesh,

The Request method calls privateLock, Process, and privateUnLock in
that order. One thing that jumps out at me is that you don't have the
Process method call wrapped in a try/catch/finally block. If an
unhandled exception is thrown in the Process method then the
privateUnLock method won't be called and all subsequent remoting calls
will be blocked indefinitely.

Brian

Sudesh Sawant wrote:
> Hello,
> We have an application which communicates using remoting. There is a
> server
> which is a Windows Service. The server exposes an object which is a
> singleton. The client is a Web Application which makes calls to the
> service.
> We are using tcp channel which is using binaryformatter by default. The
> problem is that after a certain number of remoting calls the calls dont
> get
> through to the server. The client application makes the call and hangs
> up.
> The call never reaches the service. The initial calls get through.
> Earlier we
> used http channel. Then the problem was worse. The client could not
> make more
> than 20 calls. Now it hangs up after about 100 or so calls if made
> sucessively. We had come to conclusion that it is some threadpool issue
> as we
> observed that after some time the thread count goes high. The
> observation in
> case of both http and tcp was that if the thread count crosses a
> certain
> limit, the server does not accept more calls. If the calls don't come
> successively, ie with in a short amount of time, the service does
> accept
> calls. I believe this is not a synchronization problem as we have use
> sync
> objects to protect in remoting calls. Also another point in this favor
> is
> that the same code hangs up earlier with http channel.
> The configuration for remote server is
> <system.runtime.remoting>
> <application>
> <service>
> <wellknown mode="Singleton" displayName="*****"
> type="***.***,Service.exe" objectUri="***.rem" />
> </service>
> <channels>
> <channel ref="tcp" port="1978"></channel>
> </channels>
> </application>
> </system.runtime.remoting>
>
> // This is in the shared assembly
> public __gc __interface IInterface
> {
> virtual System::String* Request(System::String* a_pRequest) = 0;
> };
>
> // This is in an assembly with the service
> public __gc class CInterface : public IInterface, public
> System::MarshalByRefObject
> {
> public:
> // Singleton Pattern applied
> virtual System::String* Request(System::String* a_pRequest) {
> privateLock(); Process(); privateUnLock();
> System::GC::Collect(); // After ading this we get to process more calls
> return "****" };
> virtual System::Object* InitializeLifetimeService() {return 0;};
> void privateRegisterForRemoting()
> {
> try
> {
>
> System::Runtime::Remoting::RemotingConfiguration:: Configure(System::AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
> System::Runtime::Remoting::RemotingServices::Marsh al(this, "***.rem");
> }
> catch(System::Exception* a_pException)
> {
> WRITETOSYSTEMLOG(a_pException);
> }
> };
> What could be the problem and how can this be addressed? We strongly
> think
> this is some threadpool issue. Or there may be some problem the way we
> use
> remoting.
> We can change it to singlecall if needed, but first we want to check
> the issue


Nov 17 '05 #4
Hello Jared,
I had attached the debugger to the service. Infact I had tried to trace it
through the client to my servce. The request goes ahead from the client and
does not reach the service. I had tried to solve the problem in the following
steps.
1. Called GC::Collect from the methods (methods which are being remotely
called). This improved the performance a lot.
2. Changed from http channel to tcp channel. Even this improved the
performance, but still the requests are limited.

When looking for number of threads, the thread count at which it stops
functioning in case of tcp is 91 and in case of http it is 54. Out of these
around 33 threads are created by the service. The other threads are spawned
at every request. If there is some time lag in between requests, the thread
count goes down. but the service stops remoting requests after the threshold
mentioned above is reached. I had found a link which recommendd changing the
threadpool size, but i want to try this as the last solution.

Cheers,
sudesh
"Jared Parsons [MSFT]" wrote:
Have you attached a debbuger to the service when the call hangs? If so how
many threads are running on the service?

--
Jared Parsons [MSFT]
ja******@online.microsoft.com
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no rights"
"Sudesh Sawant" <Su**********@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
Hi Brian,
Process is just a dummy function. The actual processing function has try
catch blocks.
My main problem is that after a certain number of remoting calls the calls
dont get through to the server. I had tied searching on the net for the
problem and found from a couple of sites that people where facing a
similar
problem. We got improvements in performance when we changed the channel to
tcp, but still it doesnot suffice. The explanation given for this was that
the clr threadpool gets exhausted and cant fork more threads for more
requests. I had tried to check with my code if there are any leaks but
then i
get the threadcount decreasing after the request has been completed, so
there
may be no such leak. But somewhere the requests have piledup at lower
level
and the pool gets exhausted
My last approach is to try singlecall.
Cheers,
Sudesh
"Brian Gideon" wrote:
Sudesh,

The Request method calls privateLock, Process, and privateUnLock in
that order. One thing that jumps out at me is that you don't have the
Process method call wrapped in a try/catch/finally block. If an
unhandled exception is thrown in the Process method then the
privateUnLock method won't be called and all subsequent remoting calls
will be blocked indefinitely.

Brian

Sudesh Sawant wrote:
> Hello,
> We have an application which communicates using remoting. There is a
> server
> which is a Windows Service. The server exposes an object which is a
> singleton. The client is a Web Application which makes calls to the
> service.
> We are using tcp channel which is using binaryformatter by default. The
> problem is that after a certain number of remoting calls the calls dont
> get
> through to the server. The client application makes the call and hangs
> up.
> The call never reaches the service. The initial calls get through.
> Earlier we
> used http channel. Then the problem was worse. The client could not
> make more
> than 20 calls. Now it hangs up after about 100 or so calls if made
> sucessively. We had come to conclusion that it is some threadpool issue
> as we
> observed that after some time the thread count goes high. The
> observation in
> case of both http and tcp was that if the thread count crosses a
> certain
> limit, the server does not accept more calls. If the calls don't come
> successively, ie with in a short amount of time, the service does
> accept
> calls. I believe this is not a synchronization problem as we have use
> sync
> objects to protect in remoting calls. Also another point in this favor
> is
> that the same code hangs up earlier with http channel.
> The configuration for remote server is
> <system.runtime.remoting>
> <application>
> <service>
> <wellknown mode="Singleton" displayName="*****"
> type="***.***,Service.exe" objectUri="***.rem" />
> </service>
> <channels>
> <channel ref="tcp" port="1978"></channel>
> </channels>
> </application>
> </system.runtime.remoting>
>
> // This is in the shared assembly
> public __gc __interface IInterface
> {
> virtual System::String* Request(System::String* a_pRequest) = 0;
> };
>
> // This is in an assembly with the service
> public __gc class CInterface : public IInterface, public
> System::MarshalByRefObject
> {
> public:
> // Singleton Pattern applied
> virtual System::String* Request(System::String* a_pRequest) {
> privateLock(); Process(); privateUnLock();
> System::GC::Collect(); // After ading this we get to process more calls
> return "****" };
> virtual System::Object* InitializeLifetimeService() {return 0;};
> void privateRegisterForRemoting()
> {
> try
> {
>
> System::Runtime::Remoting::RemotingConfiguration:: Configure(System::AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
> System::Runtime::Remoting::RemotingServices::Marsh al(this, "***.rem");
> }
> catch(System::Exception* a_pException)
> {
> WRITETOSYSTEMLOG(a_pException);
> }
> };
> What could be the problem and how can this be addressed? We strongly
> think
> this is some threadpool issue. Or there may be some problem the way we
> use
> remoting.
> We can change it to singlecall if needed, but first we want to check
> the issue


Nov 17 '05 #5
You could try isolating the problem by hacking up your service to give back
a default answer and not spawn any of it's own threads and see if you still
hit the problem

--
Jared Parsons [MSFT]
ja******@online.microsoft.com
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no rights"
"Sudesh Sawant" <Su**********@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Hello Jared,
I had attached the debugger to the service. Infact I had tried to trace it
through the client to my servce. The request goes ahead from the client
and
does not reach the service. I had tried to solve the problem in the
following
steps.
1. Called GC::Collect from the methods (methods which are being remotely
called). This improved the performance a lot.
2. Changed from http channel to tcp channel. Even this improved the
performance, but still the requests are limited.

When looking for number of threads, the thread count at which it stops
functioning in case of tcp is 91 and in case of http it is 54. Out of
these
around 33 threads are created by the service. The other threads are
spawned
at every request. If there is some time lag in between requests, the
thread
count goes down. but the service stops remoting requests after the
threshold
mentioned above is reached. I had found a link which recommendd changing
the
threadpool size, but i want to try this as the last solution.

Cheers,
sudesh
"Jared Parsons [MSFT]" wrote:
Have you attached a debbuger to the service when the call hangs? If so
how
many threads are running on the service?

--
Jared Parsons [MSFT]
ja******@online.microsoft.com
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no
rights"
"Sudesh Sawant" <Su**********@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
> Hi Brian,
> Process is just a dummy function. The actual processing function has
> try
> catch blocks.
> My main problem is that after a certain number of remoting calls the
> calls
> dont get through to the server. I had tied searching on the net for the
> problem and found from a couple of sites that people where facing a
> similar
> problem. We got improvements in performance when we changed the channel
> to
> tcp, but still it doesnot suffice. The explanation given for this was
> that
> the clr threadpool gets exhausted and cant fork more threads for more
> requests. I had tried to check with my code if there are any leaks but
> then i
> get the threadcount decreasing after the request has been completed, so
> there
> may be no such leak. But somewhere the requests have piledup at lower
> level
> and the pool gets exhausted
> My last approach is to try singlecall.
> Cheers,
> Sudesh
> "Brian Gideon" wrote:
>
>> Sudesh,
>>
>> The Request method calls privateLock, Process, and privateUnLock in
>> that order. One thing that jumps out at me is that you don't have the
>> Process method call wrapped in a try/catch/finally block. If an
>> unhandled exception is thrown in the Process method then the
>> privateUnLock method won't be called and all subsequent remoting calls
>> will be blocked indefinitely.
>>
>> Brian
>>
>> Sudesh Sawant wrote:
>> > Hello,
>> > We have an application which communicates using remoting. There is a
>> > server
>> > which is a Windows Service. The server exposes an object which is a
>> > singleton. The client is a Web Application which makes calls to the
>> > service.
>> > We are using tcp channel which is using binaryformatter by default.
>> > The
>> > problem is that after a certain number of remoting calls the calls
>> > dont
>> > get
>> > through to the server. The client application makes the call and
>> > hangs
>> > up.
>> > The call never reaches the service. The initial calls get through.
>> > Earlier we
>> > used http channel. Then the problem was worse. The client could not
>> > make more
>> > than 20 calls. Now it hangs up after about 100 or so calls if made
>> > sucessively. We had come to conclusion that it is some threadpool
>> > issue
>> > as we
>> > observed that after some time the thread count goes high. The
>> > observation in
>> > case of both http and tcp was that if the thread count crosses a
>> > certain
>> > limit, the server does not accept more calls. If the calls don't
>> > come
>> > successively, ie with in a short amount of time, the service does
>> > accept
>> > calls. I believe this is not a synchronization problem as we have
>> > use
>> > sync
>> > objects to protect in remoting calls. Also another point in this
>> > favor
>> > is
>> > that the same code hangs up earlier with http channel.
>> > The configuration for remote server is
>> > <system.runtime.remoting>
>> > <application>
>> > <service>
>> > <wellknown mode="Singleton" displayName="*****"
>> > type="***.***,Service.exe" objectUri="***.rem" />
>> > </service>
>> > <channels>
>> > <channel ref="tcp" port="1978"></channel>
>> > </channels>
>> > </application>
>> > </system.runtime.remoting>
>> >
>> > // This is in the shared assembly
>> > public __gc __interface IInterface
>> > {
>> > virtual System::String* Request(System::String* a_pRequest) = 0;
>> > };
>> >
>> > // This is in an assembly with the service
>> > public __gc class CInterface : public IInterface, public
>> > System::MarshalByRefObject
>> > {
>> > public:
>> > // Singleton Pattern applied
>> > virtual System::String* Request(System::String* a_pRequest) {
>> > privateLock(); Process(); privateUnLock();
>> > System::GC::Collect(); // After ading this we get to process more
>> > calls
>> > return "****" };
>> > virtual System::Object* InitializeLifetimeService() {return 0;};
>> > void privateRegisterForRemoting()
>> > {
>> > try
>> > {
>> >
>> > System::Runtime::Remoting::RemotingConfiguration:: Configure(System::AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
>> > System::Runtime::Remoting::RemotingServices::Marsh al(this,
>> > "***.rem");
>> > }
>> > catch(System::Exception* a_pException)
>> > {
>> > WRITETOSYSTEMLOG(a_pException);
>> > }
>> > };
>> > What could be the problem and how can this be addressed? We strongly
>> > think
>> > this is some threadpool issue. Or there may be some problem the way
>> > we
>> > use
>> > remoting.
>> > We can change it to singlecall if needed, but first we want to check
>> > the issue
>>
>>


Nov 17 '05 #6
Ok, Will try this.
Cheers,
Sudesh Sawant

"Jared Parsons [MSFT]" wrote:
You could try isolating the problem by hacking up your service to give back
a default answer and not spawn any of it's own threads and see if you still
hit the problem

--
Jared Parsons [MSFT]
ja******@online.microsoft.com
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no rights"
"Sudesh Sawant" <Su**********@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Hello Jared,
I had attached the debugger to the service. Infact I had tried to trace it
through the client to my servce. The request goes ahead from the client
and
does not reach the service. I had tried to solve the problem in the
following
steps.
1. Called GC::Collect from the methods (methods which are being remotely
called). This improved the performance a lot.
2. Changed from http channel to tcp channel. Even this improved the
performance, but still the requests are limited.

When looking for number of threads, the thread count at which it stops
functioning in case of tcp is 91 and in case of http it is 54. Out of
these
around 33 threads are created by the service. The other threads are
spawned
at every request. If there is some time lag in between requests, the
thread
count goes down. but the service stops remoting requests after the
threshold
mentioned above is reached. I had found a link which recommendd changing
the
threadpool size, but i want to try this as the last solution.

Cheers,
sudesh
"Jared Parsons [MSFT]" wrote:
Have you attached a debbuger to the service when the call hangs? If so
how
many threads are running on the service?

--
Jared Parsons [MSFT]
ja******@online.microsoft.com
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no
rights"
"Sudesh Sawant" <Su**********@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
> Hi Brian,
> Process is just a dummy function. The actual processing function has
> try
> catch blocks.
> My main problem is that after a certain number of remoting calls the
> calls
> dont get through to the server. I had tied searching on the net for the
> problem and found from a couple of sites that people where facing a
> similar
> problem. We got improvements in performance when we changed the channel
> to
> tcp, but still it doesnot suffice. The explanation given for this was
> that
> the clr threadpool gets exhausted and cant fork more threads for more
> requests. I had tried to check with my code if there are any leaks but
> then i
> get the threadcount decreasing after the request has been completed, so
> there
> may be no such leak. But somewhere the requests have piledup at lower
> level
> and the pool gets exhausted
> My last approach is to try singlecall.
> Cheers,
> Sudesh
> "Brian Gideon" wrote:
>
>> Sudesh,
>>
>> The Request method calls privateLock, Process, and privateUnLock in
>> that order. One thing that jumps out at me is that you don't have the
>> Process method call wrapped in a try/catch/finally block. If an
>> unhandled exception is thrown in the Process method then the
>> privateUnLock method won't be called and all subsequent remoting calls
>> will be blocked indefinitely.
>>
>> Brian
>>
>> Sudesh Sawant wrote:
>> > Hello,
>> > We have an application which communicates using remoting. There is a
>> > server
>> > which is a Windows Service. The server exposes an object which is a
>> > singleton. The client is a Web Application which makes calls to the
>> > service.
>> > We are using tcp channel which is using binaryformatter by default.
>> > The
>> > problem is that after a certain number of remoting calls the calls
>> > dont
>> > get
>> > through to the server. The client application makes the call and
>> > hangs
>> > up.
>> > The call never reaches the service. The initial calls get through.
>> > Earlier we
>> > used http channel. Then the problem was worse. The client could not
>> > make more
>> > than 20 calls. Now it hangs up after about 100 or so calls if made
>> > sucessively. We had come to conclusion that it is some threadpool
>> > issue
>> > as we
>> > observed that after some time the thread count goes high. The
>> > observation in
>> > case of both http and tcp was that if the thread count crosses a
>> > certain
>> > limit, the server does not accept more calls. If the calls don't
>> > come
>> > successively, ie with in a short amount of time, the service does
>> > accept
>> > calls. I believe this is not a synchronization problem as we have
>> > use
>> > sync
>> > objects to protect in remoting calls. Also another point in this
>> > favor
>> > is
>> > that the same code hangs up earlier with http channel.
>> > The configuration for remote server is
>> > <system.runtime.remoting>
>> > <application>
>> > <service>
>> > <wellknown mode="Singleton" displayName="*****"
>> > type="***.***,Service.exe" objectUri="***.rem" />
>> > </service>
>> > <channels>
>> > <channel ref="tcp" port="1978"></channel>
>> > </channels>
>> > </application>
>> > </system.runtime.remoting>
>> >
>> > // This is in the shared assembly
>> > public __gc __interface IInterface
>> > {
>> > virtual System::String* Request(System::String* a_pRequest) = 0;
>> > };
>> >
>> > // This is in an assembly with the service
>> > public __gc class CInterface : public IInterface, public
>> > System::MarshalByRefObject
>> > {
>> > public:
>> > // Singleton Pattern applied
>> > virtual System::String* Request(System::String* a_pRequest) {
>> > privateLock(); Process(); privateUnLock();
>> > System::GC::Collect(); // After ading this we get to process more
>> > calls
>> > return "****" };
>> > virtual System::Object* InitializeLifetimeService() {return 0;};
>> > void privateRegisterForRemoting()
>> > {
>> > try
>> > {
>> >
>> > System::Runtime::Remoting::RemotingConfiguration:: Configure(System::AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
>> > System::Runtime::Remoting::RemotingServices::Marsh al(this,
>> > "***.rem");
>> > }
>> > catch(System::Exception* a_pException)
>> > {
>> > WRITETOSYSTEMLOG(a_pException);
>> > }
>> > };
>> > What could be the problem and how can this be addressed? We strongly
>> > think
>> > this is some threadpool issue. Or there may be some problem the way
>> > we
>> > use
>> > remoting.
>> > We can change it to singlecall if needed, but first we want to check
>> > the issue
>>
>>


Nov 17 '05 #7
Hello Jared,
Still the problem is not resolved.
Cheers,
Sudesh

"Sudesh Sawant" wrote:
Ok, Will try this.
Cheers,
Sudesh Sawant

"Jared Parsons [MSFT]" wrote:
You could try isolating the problem by hacking up your service to give back
a default answer and not spawn any of it's own threads and see if you still
hit the problem

--
Jared Parsons [MSFT]
ja******@online.microsoft.com
http://blogs.msdn.com/jaredpar
"This posting is provided "AS IS" with no warranties, and confers no rights"
"Sudesh Sawant" <Su**********@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Hello Jared,
I had attached the debugger to the service. Infact I had tried to trace it
through the client to my servce. The request goes ahead from the client
and
does not reach the service. I had tried to solve the problem in the
following
steps.
1. Called GC::Collect from the methods (methods which are being remotely
called). This improved the performance a lot.
2. Changed from http channel to tcp channel. Even this improved the
performance, but still the requests are limited.

When looking for number of threads, the thread count at which it stops
functioning in case of tcp is 91 and in case of http it is 54. Out of
these
around 33 threads are created by the service. The other threads are
spawned
at every request. If there is some time lag in between requests, the
thread
count goes down. but the service stops remoting requests after the
threshold
mentioned above is reached. I had found a link which recommendd changing
the
threadpool size, but i want to try this as the last solution.

Cheers,
sudesh
"Jared Parsons [MSFT]" wrote:

> Have you attached a debbuger to the service when the call hangs? If so
> how
> many threads are running on the service?
>
> --
> Jared Parsons [MSFT]
> ja******@online.microsoft.com
> http://blogs.msdn.com/jaredpar
> "This posting is provided "AS IS" with no warranties, and confers no
> rights"
> "Sudesh Sawant" <Su**********@discussions.microsoft.com> wrote in message
> news:5D**********************************@microsof t.com...
> > Hi Brian,
> > Process is just a dummy function. The actual processing function has
> > try
> > catch blocks.
> > My main problem is that after a certain number of remoting calls the
> > calls
> > dont get through to the server. I had tied searching on the net for the
> > problem and found from a couple of sites that people where facing a
> > similar
> > problem. We got improvements in performance when we changed the channel
> > to
> > tcp, but still it doesnot suffice. The explanation given for this was
> > that
> > the clr threadpool gets exhausted and cant fork more threads for more
> > requests. I had tried to check with my code if there are any leaks but
> > then i
> > get the threadcount decreasing after the request has been completed, so
> > there
> > may be no such leak. But somewhere the requests have piledup at lower
> > level
> > and the pool gets exhausted
> > My last approach is to try singlecall.
> > Cheers,
> > Sudesh
> > "Brian Gideon" wrote:
> >
> >> Sudesh,
> >>
> >> The Request method calls privateLock, Process, and privateUnLock in
> >> that order. One thing that jumps out at me is that you don't have the
> >> Process method call wrapped in a try/catch/finally block. If an
> >> unhandled exception is thrown in the Process method then the
> >> privateUnLock method won't be called and all subsequent remoting calls
> >> will be blocked indefinitely.
> >>
> >> Brian
> >>
> >> Sudesh Sawant wrote:
> >> > Hello,
> >> > We have an application which communicates using remoting. There is a
> >> > server
> >> > which is a Windows Service. The server exposes an object which is a
> >> > singleton. The client is a Web Application which makes calls to the
> >> > service.
> >> > We are using tcp channel which is using binaryformatter by default.
> >> > The
> >> > problem is that after a certain number of remoting calls the calls
> >> > dont
> >> > get
> >> > through to the server. The client application makes the call and
> >> > hangs
> >> > up.
> >> > The call never reaches the service. The initial calls get through.
> >> > Earlier we
> >> > used http channel. Then the problem was worse. The client could not
> >> > make more
> >> > than 20 calls. Now it hangs up after about 100 or so calls if made
> >> > sucessively. We had come to conclusion that it is some threadpool
> >> > issue
> >> > as we
> >> > observed that after some time the thread count goes high. The
> >> > observation in
> >> > case of both http and tcp was that if the thread count crosses a
> >> > certain
> >> > limit, the server does not accept more calls. If the calls don't
> >> > come
> >> > successively, ie with in a short amount of time, the service does
> >> > accept
> >> > calls. I believe this is not a synchronization problem as we have
> >> > use
> >> > sync
> >> > objects to protect in remoting calls. Also another point in this
> >> > favor
> >> > is
> >> > that the same code hangs up earlier with http channel.
> >> > The configuration for remote server is
> >> > <system.runtime.remoting>
> >> > <application>
> >> > <service>
> >> > <wellknown mode="Singleton" displayName="*****"
> >> > type="***.***,Service.exe" objectUri="***.rem" />
> >> > </service>
> >> > <channels>
> >> > <channel ref="tcp" port="1978"></channel>
> >> > </channels>
> >> > </application>
> >> > </system.runtime.remoting>
> >> >
> >> > // This is in the shared assembly
> >> > public __gc __interface IInterface
> >> > {
> >> > virtual System::String* Request(System::String* a_pRequest) = 0;
> >> > };
> >> >
> >> > // This is in an assembly with the service
> >> > public __gc class CInterface : public IInterface, public
> >> > System::MarshalByRefObject
> >> > {
> >> > public:
> >> > // Singleton Pattern applied
> >> > virtual System::String* Request(System::String* a_pRequest) {
> >> > privateLock(); Process(); privateUnLock();
> >> > System::GC::Collect(); // After ading this we get to process more
> >> > calls
> >> > return "****" };
> >> > virtual System::Object* InitializeLifetimeService() {return 0;};
> >> > void privateRegisterForRemoting()
> >> > {
> >> > try
> >> > {
> >> >
> >> > System::Runtime::Remoting::RemotingConfiguration:: Configure(System::AppDomain::CurrentDomain->SetupInformation->ConfigurationFile);
> >> > System::Runtime::Remoting::RemotingServices::Marsh al(this,
> >> > "***.rem");
> >> > }
> >> > catch(System::Exception* a_pException)
> >> > {
> >> > WRITETOSYSTEMLOG(a_pException);
> >> > }
> >> > };
> >> > What could be the problem and how can this be addressed? We strongly
> >> > think
> >> > this is some threadpool issue. Or there may be some problem the way
> >> > we
> >> > use
> >> > remoting.
> >> > We can change it to singlecall if needed, but first we want to check
> >> > the issue
> >>
> >>
>
>
>


Nov 17 '05 #8
So even the dummy call of service hangs after 91 times? if so - maybe the
problem lays on client side. how many clients do you use to test this? are
they multithreaded? how many proxies do you create on client side?

Peter
Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: cppaddict | last post by:
Hi, In this tutorial on singleton class in C++ (http://gethelp.devx.com/techtips/cpp_pro/10min/10min0200.asp) the author gives two implementations of a simple singleton class, claiming that...
1
by: Jim Strathmeyer | last post by:
So I'm trying to implement a singleton template class, but I'm getting a confusing 'undefined reference' when it tries to link. Here's the code and g++'s output. Any help? // singleton.h ...
3
by: Harry | last post by:
Hi ppl I have a doubt on singleton class. I am writing a program below class singleton { private: singleton(){}; public: //way 1
7
by: Stephen Brown | last post by:
I have some strange behavior on my web server that seems to point to garbage collection. I have a singleton that tracks web activity on my web site. The singleton works great, except that it...
21
by: Sharon | last post by:
I wish to build a framework for our developers that will include a singleton pattern. But it can not be a base class because it has a private constructor and therefore can be inherit. I thought...
3
by: dischdennis | last post by:
Hello List, I would like to make a singleton class in python 2.4.3, I found this pattern in the web: class Singleton: __single = None def __init__( self ): if Singleton.__single: raise...
6
by: toton | last post by:
Hi, If I have a singleton class based on dynamic initialization (with new ) , is it considered a memory leak? Anything in C++ standard says about it ? And little off - topic question , If the...
3
by: wizwx | last post by:
There are two typical implementations of a singleton. The first one is to use a static pointer class Singleton { static Singleton * pSingleton; public: Singleton * instance() {...
2
by: Bob Johnson | last post by:
Just wondering the extent to which some of you are implementing classes as Singletons. I'm working on a brand new project and, early on, identified some obvious candidates. By "obvoius candidates"...
4
by: John Doe | last post by:
Hi, I have a singleton class defined like this : class UIManager : public CSingleton<UIManager>, public CObject { protected: DECLARE_DYNAMIC(UIManager) friend class CSingleton<UIManager>;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.