views:

497

answers:

8

Hello,

I'm working on a client-server solution that uses .NET 2.0 Remoting (server activation, binary formatting over TCP channel, Vista Ultimate) for communication purposes. Currently I'm profiling the application and run everything on the same machine. I noticed that if I start the application, everything works just fine for several minutes and then suddenly each remote call takes several seconds to execute. I have logging on both ends and clock every call. Server side's implementation takes only fraction of a second to execute, while the whole remote call is slow. Further profiling showed that remoting degrades on the server side: while inner working of the remote service execute within a fraction of a second, the responses are very slow. If I restart server everything backs to normal for several minutes again.

Did anyone experience something like that?

Thanks!

UPDATE: I checked, if I configure lifetime for my remote object to, say, 1 day, I still have the same problem.

UPDATE: I'm using the pattern suggested by Ingo Ramer ( http://tinyurl.com/5u8fjq ) for all my remoting stuff, if this makes any difference.

Client code:

public static object CreateInstance(Type type)
{
    if (!Initialized)
        InitWellKnownTypesCache();

    WellKnownClientTypeEntry typeEntry = (WellKnownClientTypeEntry)wellKnownTypesCache[type];
    if (null == typeEntry)
        throw new RemotingException("Type not found.");

    if (string.IsNullOrEmpty(serverObjectActivationUri))
        throw new RemotingException("ServerObjectActivationUri wasn't configured. Cannot create server object instance.");

    return Activator.GetObject(typeEntry.ObjectType, string.Format(serverObjectActivationUri, typeEntry.ObjectUrl));
}

Server side has nothing but proper config file that looks like:

        <service>
            <wellknown 
                mode="Singleton" 
                type="MyDomain.SomeDomain, MyDomain" 
                objectUri="SomeDomainService"
            />

I don't do anything beyond RemotingConfiguration.Configure("MyDomainService.exe.config", false); neither in my server nor client code.

A: 

Never. Are you doing something that's causing extra instances of your remoting layer to be registered/instantiated??

Dave Markle
I don't think so. I'm using the pattern suggested by Ingo Ramer ( http://tinyurl.com/5u8fjq ) for all my remoting stuff, if this makes any difference.
A: 

A glance at your code, or a subset thereof, would also help.

BryCoBat
+1  A: 

Use some network monitoring tool like Wireshark to see if your problem is network related or server sync related.

If it proves that it is not a network issue, then try to attach a simple custom sync in the chain (just before the channel) to log and get the timing between the hooks.

Sunny
A: 

Are you sponsoring your remoted objects with a client sponsor?

Patrik
I don't do this explicitly for sure. As I described in my question, I tried to play with server-side lifetime settings with no result.I also posted some code. Hope it will help.
A: 

I changed my remoting channel's type from tcp to http, while leaving the binary formatting. I can see the same slowdown in several minutes of inactivity, but unlike the tcp channels, after the client makes a "slow" remote call, the server "wakes up" and all subsequent calls are fast, until next period of inactivity comes and server goes asleep again.

No way this is a solution, but at least some sort of workaround.

A: 

It could be related with lifetime lease. A Singleton object is subject to the lifetime lease that was specified for it, so it can be recycled even if clients currently hold references to it. You can create the former type of Singleton object by overriding the InitializeLifetimeService method of MarshalByRefObject.

peanut
A: 

Can you try MTAThread attribute for your class, just a thought..

rsapru
A: 

Are you by chance making large numbers of remoting calls? If you're making the calls fast enough you could be running out of threads to handle the requests.

That's probably not your issue, but I've run into that before so I thought I pass that along.

Kevin Tighe
No, it's like up to 5 calls in during my testing.