Some server “stress” tests Can our TCP concurrent server simultaneous connections?

Download Report

Transcript Some server “stress” tests Can our TCP concurrent server simultaneous connections?

Some server “stress” tests
Can our TCP concurrent server
handle many successive and/or
simultaneous connections?
‘tcpserver3.cpp’
• This version of our concurrent server used
a signal-handler to call ‘wait()’ whenever a
child-process disconnected from a client
and invoked the ‘exit()’ system-call
• It seemed to eliminate ‘zombie’ processes
• But we didn’t yet see how it performs in
case multiple simultaneous connections
are initiated by a client application
‘sixlinks.cpp’
• A modification of our ‘tcpclient2.cpp’ that
will attempt to establish six simultaneous
connections with our ‘tcpserver3.cpp’
• It does seem successful in responding to
these client-requests very promptly, but we
need to check for ‘zombie’ processes
• Is there a problem? If so, why? And how
can we ‘fix’ that problem?
‘waitpid()’
• There’s a more general form of the UNIX
‘wait()’ function which allows the caller to
request ‘non-blocking’ behavior using an
option-flag:
$ waitpid( -1, NULL, WNOHANG );
‘wait’ for any child-process
we don’t need any ‘status’ info
return immediately to the caller without blocking
The function-value returned will be 0 if no more child-processes have exited
without already having been waited for; or will be equal to the PID of a child
that had earlier exited and was just now ‘waited for’ by this function-call
‘tcpserver4.cpp’
• Modifies one line of the signal-handler in
our ‘tcpserver3.cpp’ concurrent server so
that all child-processes that have exited
are ‘waited for’ before resuming the task
• Changes:
wait( NULL );
• To:
while ( waitpid( -1, NULL, WNOHANG ) > 0 );
‘tcpstress.cpp’
• This demo modifies our ‘tcpclient2.cpp’ so
that it make a large number of separate
connection-requests and data-exchanges
in rapid succession, to test the server’s
ability to respond promptly and correctly
acknowledgement
• The ideas used to motivate the ‘concurrent
TCP server’ here are adaptations from the
presentation by W. Richard Stevens in his
classic text “UNIX Network Programming,
2nd Ed”, Prentice-Hall (1998), volume 1
In-class exercise #1
• Can you modify our ‘sixlinks.cpp’ program
so that it will establish a much larger set of
simultaneous connections? How many
can you successfully establish before the
system’s resources are exhausted?
In-class exercise #2
• Is there any upper limit on the number of
consecutive connection-requests that our
‘tcpstress.cpp’ client can establish, given
the fact that each connection-request is
closed (and system resources released)
before the next connection is attempted?