Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

All the good, offered solutions so far are heavily geared by the idea of "time" (ie, connections per second). This is not what is being asked. The maximum connections limit is a per server parameter that controls, more or less, how many accept()ed TCP connections are there in the server side.

What ibanix needs to know, is if the server will process more than 100 concurrent connections in any time frame, which is not exactly the same problem.

In order to test this, execute this simple script (I called it nsock) and pay attention to what happens...

#!/usr/bin/perl use strict; use warnings; use Getopt::Std; use IO::Socket::INET; use vars qw($opt_s $opt_p $opt_n); getopts("s:p:n:"); die <<EOF nsock -s server [-p port] [-n number] -s: server to connect to -p: port to connect to. Defaults to 80 -n: number of concurrent connections. Defaults to 100 EOF unless $opt_s; $opt_p ||= 80; $opt_n ||= 100; my @socks = (); $| = 1; for my $c (1 .. $opt_n) { print ">>> Socket #$c\n"; my $s = new IO::Socket::INET->new ( PeerAddr => $opt_s, PeerPort => $opt_p, Proto => 'tcp', Timeout => 30, ); unless ($s) { warn "Failed to create socket $c: $!\n"; sleep 2; redo; } print "<<< $c connected ok\n"; push @socks, $s; } print "*** All concurrent connections done!\n";

What it does is simply, open a TCP socket to the desired server and keep it open. If you run it with slightly larger number of connections (say, 101) you should see the 101th connection take forever to establish. This happens because it is going into the accept() queue and not established right away.

If you run it with 100 connections, all of them should be established. Hope this helps.

Best regards

-lem, but some call me fokat


In reply to Re: Stress testing a web server by fokat
in thread Stress testing a web server by ibanix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found