Note that there are some explanatory texts on larger screens.

plurals
  1. POSpikes in Socket Performance
    text
    copied!<p>We are facing random spikes in high throughput transaction processing system using sockets for IPC.</p> <p>Below is the setup used for the run:</p> <ol> <li>The client opens and closes new connection for every transaction, and there are 4 exchanges between the server and the client.</li> <li>We have disabled the <code>TIME_WAIT</code>, by setting the socket linger (<code>SO_LINGER</code>) option via getsockopt as we thought that the spikes were caused due to the sockets waiting in <code>TIME_WAIT</code>.</li> <li>There is no processing done for the transaction. Only messages are passed.</li> <li>OS used Centos 5.4</li> </ol> <p>The average round trip time is around 3 milli seconds, but some times the round trip time ranges from 100 milli seconds to couple of seconds. </p> <p><strong>Steps used for Execution and Measurement and output</strong></p> <ol> <li><p>Starting the server</p> <p>$ python sockServerLinger.py > /dev/null &amp;</p></li> <li><p>Starting the client to post 1 million transactions to the server. And logs the time for a transaction in the client.log file.</p> <p>$ python sockClient.py 1000000 > client.log</p></li> <li><p>Once the execution finishes the following command will show the execution time greater than 100 milliseconds in the format <code>&lt;line_number&gt;:&lt;execution_time&gt;</code>. </p> <p>$ grep -n "0.[1-9]" client.log | less</p></li> </ol> <p>Below is the example code for Server and Client.</p> <p><strong>Server</strong></p> <pre><code># File: sockServerLinger.py import socket, traceback,time import struct host = '' port = 9999 l_onoff = 1 l_linger = 0 lingeropt = struct.pack('ii', l_onoff, l_linger) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, lingeropt) s.bind((host, port)) s.listen(1) while 1: try: clientsock, clientaddr = s.accept() print "Got connection from", clientsock.getpeername() data = clientsock.recv(1024*1024*10) #print "asdasd",data numsent=clientsock.send(data) data1 = clientsock.recv(1024*1024*10) numsent=clientsock.send(data) ret = 1 while(ret&gt;0): data1 = clientsock.recv(1024*1024*10) ret = len(data) clientsock.close() except KeyboardInterrupt: raise except: print traceback.print_exc() continue </code></pre> <p><strong>Client</strong> </p> <pre><code># File: sockClient.py import socket, traceback,sys import time i = 0 while 1: try: st = time.time() s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) while (s.connect_ex(('127.0.0.1',9999)) != 0): continue numsent=s.send("asd"*1000) response = s.recv(6000) numsent=s.send("asd"*1000) response = s.recv(6000) i+=1 if i == int(sys.argv[1]): break except KeyboardInterrupt: raise except: print "in exec:::::::::::::",traceback.print_exc() continue print time.time() -st </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload