PC Review


Reply
Thread Tools Rate Thread

Socket Performance vs Direct communication

 
 
pawan
Guest
Posts: n/a
 
      24th Jul 2006
Hi

While performance/stress testing my application (a COM+ Server
component) we drive the transaction to the component via a Socket
Server app, listening to a port and passing the incomming transactions
to the COM+ application. The Socket App then returns the response back
over the opened socket to the client. For a 100 users scenario, 8 CPU
box I am able to get 130 Transactions per seconds.

How ever if I try to pass these transactions directly to an instance of
the COM+ component without the Socket Server, I get performance of 190
Transactions per seconds.

Does spawning a Socket Server really incurr that kind of an overhead,
in this case it is 30%, or I am doing smething wrong with the Socket
Server app. It runs Async and spawns a new thread for each new
connection.

Thanks in Advance
Pawan

 
Reply With Quote
 
 
 
 
Barry Kelly
Guest
Posts: n/a
 
      24th Jul 2006
"pawan" <(E-Mail Removed)> wrote:

> Does spawning a Socket Server really incurr that kind of an overhead,
> in this case it is 30%, or I am doing smething wrong with the Socket
> Server app. It runs Async and spawns a new thread for each new
> connection.


I don't understand this bit - one of the main points of using
asynchronous sockets is so that you don't have a new thread for each
connection.

-- Barry

--
http://barrkel.blogspot.com/
 
Reply With Quote
 
pawan
Guest
Posts: n/a
 
      25th Jul 2006

Hi Berry

appologies for the confusing statement there. What I meant was that the
Socket Server is running Asynchronously. What is really bugging me is
that the system performance takes a big hit when sending the
transactions thru sockets.

here's what the code looks like:



void CreateServer()
{
int nPort = GetPortNumber();
serverSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,
ProtocolType.Tcp);
IPEndPoint ipLocal = new IPEndPoint (IPAddress.Any, nPort);
serverSocket.Bind( ipLocal );
serverSocket.Listen(100);
serverSocket.BeginAccept(new AsyncCallback (OnConnectRequest), null);
}

public void OnConnectRequest(IAsyncResult asyncRes)
{
Socket workerSocket = serverSocket.EndAccept (asyncRes);
Interlocked.Increment(ref m_clientCount);
m_workerSocketList.Add(workerSocket);
TransManager txnProcThread = new TransManager(m_clientCount,
fieldDescFilePath, ref htFieldDescList, componentName);
txnProcThread.Init();
htTxnProc.Add(m_clientCount, txnProcThread );
AwaitNOFData(workerSocket, m_clientCount);
ratlServerSocket.BeginAccept(new AsyncCallback ( OnConnectRequest
),null);
}

public void AwaitNOFData(System.Net.Sockets.Socket soc, int
clientNumber)
{
if ( pfnWorkerCallBack == null )
{ pfnWorkerCallBack = new AsyncCallback (ReadNOFData); }
SocketPacket theSocPkt = new SocketPacket (soc, clientNumber);
soc.BeginReceive (theSocPkt.dataBuffer, 0,
theSocPkt.dataBuffer.Length, SocketFlags.None,
pfnWorkerCallBack, theSocPkt);
}



public void ReadNOFData(IAsyncResult asyn)
{
SocketPacket socketData = (SocketPacket)asyn.AsyncState ;
int iRx = socketData.m_currentSocket.EndReceive(asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(socketData.dataBuffer, 0, iRx, chars, 0);

//Get the input data into string format for invoking PROCESS MESSAGE
string szData = new System.String(chars);
// READ THE INPUT DATA AND INVOKE THE TRANSACTION

try
{
TransManager currentTxn =
(TransManager)htTxnProc[socketData.m_clientNumber];
string returnMsg = currentTxn.DoProcessMsg(szData);
byte[] byData = System.Text.Encoding.ASCII.GetBytes(returnMsg);
Prevresponse = returnMsg.ToString();
Socket workerSocket = (Socket)socketData.m_currentSocket;
workerSocket.Send(byData);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
throw;
}

// Continue the waiting for data on the Socket
AwaitNOFData(socketData.m_currentSocket, socketData.m_clientNumber );
}


Regards
Pawan

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c# and c++ socket communication Yu Microsoft C# .NET 2 4th May 2009 12:24 PM
asynchronous socket communication panko Microsoft C# .NET 8 26th Jan 2007 06:16 PM
Socket communication Scott Microsoft VB .NET 2 3rd Jun 2005 11:53 AM
Socket communication problem Sašo Zagoranski Microsoft C# .NET 4 23rd May 2005 12:17 AM
Socket Communication behind LAN Yassar Microsoft C# .NET 2 22nd Oct 2003 05:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:25 PM.