Net Remoting and Performace

  • Thread starter How to get a common name(CN) of SSL
  • Start date
H

How to get a common name(CN) of SSL

Hello..
EveryOne..

i want to use the NET Remote between Server and Client.

But it was not good about the CPU Usage and sending time, whie i tested the
NET Remote.

so i write my code below..

[Server Side]

1. I made a Remote Server using TCPChannel.
try
{
m_channel = new TcpChannel(nPortNumber);
ChannelServices.RegisterChannel(m_channel, false);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(CReceiverParameterFromThird), strCentralName,
WellKnownObjectMode.Singleton);
}
catch (Exception ex)
{
Console.WriteLine("CreateCentral :" + ex.Message);
return false;
}

2. And i made a some of funtions like below.
But All Of Functions are nothing to do, they just write some text through
Console.

public class CReceiverParameterFromThird : MarshalByRefObject
{

public bool CreateParameter(string strId, string strName, int
nLength)
{
Console.WriteLine("CreateParameter : {0}
{1}:{2}ms",nLength.ToString(), DateTime.Now, DateTime.Now.Millisecond);
return true;
}

[Client Side]

1.The Remote Object was created like below.
m_receiverParameter =
(CReceiverParameterFromThird)Activator.GetObject(typeof(CReceiverParameterFromThird), "tcp://" + strCentralIP +":" + strPortNumber + "/" + "Central");

2.The Client will call a Remote Functions.
m_receiverParameter.CreateParameter(strId, strName, nLength);

[How to Test]

1.I called a Remote Functions like below.
static void Main(string[] args)
{
CCentralClient CentralClient = new CCentralClient();

CentralClient.CreateReceiver("10.1.2.220", "7000");

for (int i = 0; i < 20000; i++)
{
CentralClient.CreateParameter("1", "PM", i);
--- any of Remote Functions.----

Thread.Sleep(TimeSpan.FromMilliseconds(100));
}
}
}
After i call a Remote Function, The CPU Usage is increased both Server and
Client
about 2%~5%.

How can i solve this kind of problem, because i want to send a lot of data
and as soon as faster from Client To Server.


anyone help me how to solve this kind of problem.
 
M

Mr. Arnold

"How to get a common name(CN) of SSL"

How can i solve this kind of problem, because i want to send a lot of data
and as soon as faster from Client To Server.


anyone help me how to solve this kind of problem.

You use the Binary Formatters, serialize the data, and compress the data.
You deserialize and uncompress the data on the other side.
 
H

How to get a common name(CN) of SSL

Mr. Arnold said:
"How to get a common name(CN) of SSL"



You use the Binary Formatters, serialize the data, and compress the data.
You deserialize and uncompress the data on the other side.

Thank you for your reply,

Could you show me a sample program about binary formatter, Serialize and
Compress the data.

because i don't know how to do that very well.
 
W

Willy Denoyette [MVP]

"How to get a common name(CN) of SSL"
Hello..
EveryOne..

i want to use the NET Remote between Server and Client.

But it was not good about the CPU Usage and sending time, whie i tested
the
NET Remote.

so i write my code below..

[Server Side]

1. I made a Remote Server using TCPChannel.
try
{
m_channel = new TcpChannel(nPortNumber);
ChannelServices.RegisterChannel(m_channel, false);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(CReceiverParameterFromThird),
strCentralName,
WellKnownObjectMode.Singleton);
}
catch (Exception ex)
{
Console.WriteLine("CreateCentral :" + ex.Message);
return false;
}

2. And i made a some of funtions like below.
But All Of Functions are nothing to do, they just write some text through
Console.

public class CReceiverParameterFromThird : MarshalByRefObject
{

public bool CreateParameter(string strId, string strName, int
nLength)
{
Console.WriteLine("CreateParameter : {0}
{1}:{2}ms",nLength.ToString(), DateTime.Now, DateTime.Now.Millisecond);
return true;
}

[Client Side]

1.The Remote Object was created like below.
m_receiverParameter =
(CReceiverParameterFromThird)Activator.GetObject(typeof(CReceiverParameterFromThird),
"tcp://" + strCentralIP +":" + strPortNumber + "/" + "Central");

2.The Client will call a Remote Functions.
m_receiverParameter.CreateParameter(strId, strName, nLength);

[How to Test]

1.I called a Remote Functions like below.
static void Main(string[] args)
{
CCentralClient CentralClient = new CCentralClient();

CentralClient.CreateReceiver("10.1.2.220", "7000");

for (int i = 0; i < 20000; i++)
{
CentralClient.CreateParameter("1", "PM", i);
--- any of Remote Functions.----

Thread.Sleep(TimeSpan.FromMilliseconds(100));
}
}
}
After i call a Remote Function, The CPU Usage is increased both Server and
Client
about 2%~5%.

How can i solve this kind of problem, because i want to send a lot of data
and as soon as faster from Client To Server.


anyone help me how to solve this kind of problem.



You don't actually describe a "problem", 2-5% CPU increase is not a problem.
You don't mention the measured transfer time, the expected response time and
how you measured, you also need to tell us in what context you have used
this test bed, are the clients running on the same box? If not what's the
distance between the two (LAN, WAN etc..).
And..... why do you sleep 100msec between calls?

Willy.
 
L

lightdoll

Willy Denoyette said:
"How to get a common name(CN) of SSL"
Hello..
EveryOne..

i want to use the NET Remote between Server and Client.

But it was not good about the CPU Usage and sending time, whie i tested
the
NET Remote.

so i write my code below..

[Server Side]

1. I made a Remote Server using TCPChannel.
try
{
m_channel = new TcpChannel(nPortNumber);
ChannelServices.RegisterChannel(m_channel, false);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(CReceiverParameterFromThird),
strCentralName,
WellKnownObjectMode.Singleton);
}
catch (Exception ex)
{
Console.WriteLine("CreateCentral :" + ex.Message);
return false;
}

2. And i made a some of funtions like below.
But All Of Functions are nothing to do, they just write some text through
Console.

public class CReceiverParameterFromThird : MarshalByRefObject
{

public bool CreateParameter(string strId, string strName, int
nLength)
{
Console.WriteLine("CreateParameter : {0}
{1}:{2}ms",nLength.ToString(), DateTime.Now, DateTime.Now.Millisecond);
return true;
}

[Client Side]

1.The Remote Object was created like below.
m_receiverParameter =
(CReceiverParameterFromThird)Activator.GetObject(typeof(CReceiverParameterFromThird),
"tcp://" + strCentralIP +":" + strPortNumber + "/" + "Central");

2.The Client will call a Remote Functions.
m_receiverParameter.CreateParameter(strId, strName, nLength);

[How to Test]

1.I called a Remote Functions like below.
static void Main(string[] args)
{
CCentralClient CentralClient = new CCentralClient();

CentralClient.CreateReceiver("10.1.2.220", "7000");

for (int i = 0; i < 20000; i++)
{
CentralClient.CreateParameter("1", "PM", i);
--- any of Remote Functions.----

Thread.Sleep(TimeSpan.FromMilliseconds(100));
}
}
}
After i call a Remote Function, The CPU Usage is increased both Server and
Client
about 2%~5%.

How can i solve this kind of problem, because i want to send a lot of data
and as soon as faster from Client To Server.


anyone help me how to solve this kind of problem.



You don't actually describe a "problem", 2-5% CPU increase is not a problem.
You don't mention the measured transfer time, the expected response time and
how you measured, you also need to tell us in what context you have used
this test bed, are the clients running on the same box? If not what's the
distance between the two (LAN, WAN etc..).
And..... why do you sleep 100msec between calls?

Willy.

Thank you for your reply.

I have alredy mentioned something to send a lot of data to server from client.

I just send a little data for this test before making a program.

so The Cpu usage isn't good between server and client.

i want to solve this problem before making a program.

so if i call a function of Remote, then Both the Cpu Usage of Server and
Client are increased, so it isn't good for server and client,

i have tested this function in same pc or separated pc.

you can see there is a variable of i in for loop,

if The Client send a lot of data to server in same pc continually,

i found the time based of i's value from Server and Client,

Of course i also used LAN,

Actually, i want to use less than 100msec,
i think
it is difficult to control OS

Thank you...

do you have any idea to solve this problem.

if you need my code, i can give you my code..^^

bye
 
W

Willy Denoyette [MVP]

lightdoll said:
Willy Denoyette said:
"How to get a common name(CN) of SSL"
Hello..
EveryOne..

i want to use the NET Remote between Server and Client.

But it was not good about the CPU Usage and sending time, whie i tested
the
NET Remote.

so i write my code below..

[Server Side]

1. I made a Remote Server using TCPChannel.
try
{
m_channel = new TcpChannel(nPortNumber);
ChannelServices.RegisterChannel(m_channel, false);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(CReceiverParameterFromThird),
strCentralName,
WellKnownObjectMode.Singleton);
}
catch (Exception ex)
{
Console.WriteLine("CreateCentral :" + ex.Message);
return false;
}

2. And i made a some of funtions like below.
But All Of Functions are nothing to do, they just write some text
through
Console.

public class CReceiverParameterFromThird : MarshalByRefObject
{

public bool CreateParameter(string strId, string strName,
int
nLength)
{
Console.WriteLine("CreateParameter : {0}
{1}:{2}ms",nLength.ToString(), DateTime.Now, DateTime.Now.Millisecond);
return true;
}

[Client Side]

1.The Remote Object was created like below.
m_receiverParameter =
(CReceiverParameterFromThird)Activator.GetObject(typeof(CReceiverParameterFromThird),
"tcp://" + strCentralIP +":" + strPortNumber + "/" + "Central");

2.The Client will call a Remote Functions.
m_receiverParameter.CreateParameter(strId, strName, nLength);

[How to Test]

1.I called a Remote Functions like below.
static void Main(string[] args)
{
CCentralClient CentralClient = new CCentralClient();

CentralClient.CreateReceiver("10.1.2.220", "7000");

for (int i = 0; i < 20000; i++)
{
CentralClient.CreateParameter("1", "PM", i);
--- any of Remote Functions.----

Thread.Sleep(TimeSpan.FromMilliseconds(100));
}
}
}
After i call a Remote Function, The CPU Usage is increased both Server
and
Client
about 2%~5%.

How can i solve this kind of problem, because i want to send a lot of
data
and as soon as faster from Client To Server.


anyone help me how to solve this kind of problem.



You don't actually describe a "problem", 2-5% CPU increase is not a
problem.
You don't mention the measured transfer time, the expected response time
and
how you measured, you also need to tell us in what context you have used
this test bed, are the clients running on the same box? If not what's the
distance between the two (LAN, WAN etc..).
And..... why do you sleep 100msec between calls?

Willy.

Thank you for your reply.

I have alredy mentioned something to send a lot of data to server from
client.

I just send a little data for this test before making a program.

so The Cpu usage isn't good between server and client.

i want to solve this problem before making a program.

so if i call a function of Remote, then Both the Cpu Usage of Server and
Client are increased, so it isn't good for server and client,

i have tested this function in same pc or separated pc.

you can see there is a variable of i in for loop,

if The Client send a lot of data to server in same pc continually,

i found the time based of i's value from Server and Client,

Of course i also used LAN,

Actually, i want to use less than 100msec,
i think
it is difficult to control OS

Thank you...

do you have any idea to solve this problem.

if you need my code, i can give you my code..^^

bye



Hmmm... it looks like you want to call a remoted method 20000 times without
consuming CPU resources and it should not take longer than 100msec, please
correct me if I'm wrong. This is however not possible, calling methods
(whatever) will always consume CPU cycles, what else did you expect?
To know exactly how long a single call takes, you can use the Stopwatch
class and measure how long it takes to execute, say 1000 calls.


Willy.
 
L

lightdoll

Willy Denoyette said:
lightdoll said:
Willy Denoyette said:
"How to get a common name(CN) of SSL"
Hello..
EveryOne..

i want to use the NET Remote between Server and Client.

But it was not good about the CPU Usage and sending time, whie i tested
the
NET Remote.

so i write my code below..

[Server Side]

1. I made a Remote Server using TCPChannel.
try
{
m_channel = new TcpChannel(nPortNumber);
ChannelServices.RegisterChannel(m_channel, false);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(CReceiverParameterFromThird),
strCentralName,
WellKnownObjectMode.Singleton);
}
catch (Exception ex)
{
Console.WriteLine("CreateCentral :" + ex.Message);
return false;
}

2. And i made a some of funtions like below.
But All Of Functions are nothing to do, they just write some text
through
Console.

public class CReceiverParameterFromThird : MarshalByRefObject
{

public bool CreateParameter(string strId, string strName,
int
nLength)
{
Console.WriteLine("CreateParameter : {0}
{1}:{2}ms",nLength.ToString(), DateTime.Now, DateTime.Now.Millisecond);
return true;
}

[Client Side]

1.The Remote Object was created like below.
m_receiverParameter =
(CReceiverParameterFromThird)Activator.GetObject(typeof(CReceiverParameterFromThird),
"tcp://" + strCentralIP +":" + strPortNumber + "/" + "Central");

2.The Client will call a Remote Functions.
m_receiverParameter.CreateParameter(strId, strName, nLength);

[How to Test]

1.I called a Remote Functions like below.
static void Main(string[] args)
{
CCentralClient CentralClient = new CCentralClient();

CentralClient.CreateReceiver("10.1.2.220", "7000");

for (int i = 0; i < 20000; i++)
{
CentralClient.CreateParameter("1", "PM", i);
--- any of Remote Functions.----

Thread.Sleep(TimeSpan.FromMilliseconds(100));
}
}
}
After i call a Remote Function, The CPU Usage is increased both Server
and
Client
about 2%~5%.

How can i solve this kind of problem, because i want to send a lot of
data
and as soon as faster from Client To Server.


anyone help me how to solve this kind of problem.



You don't actually describe a "problem", 2-5% CPU increase is not a
problem.
You don't mention the measured transfer time, the expected response time
and
how you measured, you also need to tell us in what context you have used
this test bed, are the clients running on the same box? If not what's the
distance between the two (LAN, WAN etc..).
And..... why do you sleep 100msec between calls?

Willy.

Thank you for your reply.

I have alredy mentioned something to send a lot of data to server from
client.

I just send a little data for this test before making a program.

so The Cpu usage isn't good between server and client.

i want to solve this problem before making a program.

so if i call a function of Remote, then Both the Cpu Usage of Server and
Client are increased, so it isn't good for server and client,

i have tested this function in same pc or separated pc.

you can see there is a variable of i in for loop,

if The Client send a lot of data to server in same pc continually,

i found the time based of i's value from Server and Client,

Of course i also used LAN,

Actually, i want to use less than 100msec,
i think
it is difficult to control OS

Thank you...

do you have any idea to solve this problem.

if you need my code, i can give you my code..^^

bye



Hmmm... it looks like you want to call a remoted method 20000 times without
consuming CPU resources and it should not take longer than 100msec, please
correct me if I'm wrong. This is however not possible, calling methods
(whatever) will always consume CPU cycles, what else did you expect?
To know exactly how long a single call takes, you can use the Stopwatch
class and measure how long it takes to execute, say 1000 calls.


Willy.

Thank you for your reply.

As soon as possible i want to call the faster remoted method , Not lose the
Cpu resource.

Can i...?ã… ã… 
 
M

Mr. Arnold

"How to get a common name(CN) of SSL"
Thank you for your reply,

Could you show me a sample program about binary formatter, Serialize and
Compress the data.

because i don't know how to do that very well.

There is a project for Contacts on how to use a Binary Formatter.

http://docs.msdnaa.net/ark_new3.0/cd3/content/Tech_Visual CSharp.htm


What you'll want to do is have a Class/object on the client side and server
the same object that represents the data. You're going to populate the
object with your data with object accessor properties that represent your
data int, string, double, etc. You'll use the [Serializable] attribute at
the top of the class. You'll serialize the object to XML using a Memory
Stream. You send the data to the server, and you'll deserialize it back into
the object. Again, the class must be on the client and server sides.


Here is some code for compressing data. You'll notice that it's doing it
with a Memory Stream, using sharpziplib.

http://www.google.com/search?hl=en&q=sharpziplib&btnG=Google+Search

As for the .Net Remoting and Binary Formatter on the TCP, you can use Google
and look it up.

HTH

public static string GetFileData( string filename, SAISDataFormat format )

{

//Make sure the file exists

if(!File.Exists(filename))

throw new Exception("FILE DOES NOT EXIST!");

//Get the file data

StreamReader reader = new StreamReader( filename );

string data = reader.ReadToEnd();

reader.Close();

//Check if we should compress the data

MemoryStream ms = null;

Stream output = null;

switch(format)

{

case SAISDataFormat.XML:

return data;

case SAISDataFormat.XML_BZ:

ms = new MemoryStream();

output = new BZip2OutputStream( ms );

break;

case SAISDataFormat.XML_GZ:

ms = new MemoryStream();

output = new GZipOutputStream( ms );

break;

}

//Compress the data by writing it to the output stream

byte[] buffer = System.Text.Encoding.Unicode.GetBytes ( data );

output.Write( buffer, 0, buffer.Length );

output.Close();

//Read out the compressed data and base64 encode it

buffer = ms.GetBuffer();

ms.Close();

string outputBase64 = Convert.ToBase64String( buffer );


//Return the Base64 encoding file data

return outputBase64;

}

/// <summary>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top