473,396 Members | 1,998 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,396 software developers and data experts.

Socket Performance vs Direct communication

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

Jul 24 '06 #1
2 1212
"pawan" <pa*******@msn.comwrote:
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/
Jul 24 '06 #2

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.Strea m,
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

Jul 25 '06 #3

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

Similar topics

4
by: faktujaa | last post by:
Hi, I am having some problem with callback used in socket implementation. private static void Connect(string strPrtrIPAddr, int intPrtrPort, ref Socket rsocClient) { try { // Create remote end...
7
by: Adam Clauss | last post by:
I am trying to work-around a firewall which limits me to only being able to accept inbound connections on port 80. Unfortunately, I need to two different applications to be able to accept...
9
by: Michael Lindsey | last post by:
I need to write a server app to send images to client GUIs that are outside of the server's domain. The client will have the file system path to the image but can not access the file system. I am...
3
by: Ricardo Quintanilla | last post by:
i had a problem whom i do not know how to explain. i was using a TcpClient (System.Net.Sockets.TcpClient) object to send and receive data to an AS400 socket. Two months ago it started to work...
4
by: Sačo Zagoranski | last post by:
Hi! I'm writing a simple 3D First person shooter game. It is a multiplayer game, where all the players connect to one server.
1
by: Mr. Beck | last post by:
Hello, Please Help..... I have been working with some tcp/ip socket communication within a C# program recently. Basicly, I have a program (myProblemProgram) that has a socket connected to...
0
by: =?Utf-8?B?QWxwZXIgQUtDQVlPWg==?= | last post by:
Hello, First of all I wish you a good day. My help request is about .NET asynchrounus socket communication. I have developed Server-Client Windows Forms .NET applications in VC++ .NET v2003. I...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
0
by: Mangabasi | last post by:
Howdy, I would like to use the Synthesis Toolkit for a demo. I downloaded the STK from http://ccrma.stanford.edu/software/stk/index.html. It seems very powerful and user friendly. There are...
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:
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.