473,513 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server Load Testing

1 New Member
hi,
i need to write a perl client script to create 5000 socket connections at the same time.
Expand|Select|Wrap|Line Numbers
  1. use IO::Socket;
  2. use diagnostics;
  3. use POSIX qw(strftime); 
  4. my $i;
  5. my $connections = 5000;
  6.  
  7. foreach my $i (1...$connections)
  8.     {
  9.         repeat();
  10.     }
  11.  
  12. sub repeat
  13. {
  14.     my $remote_host = "192.168.1.57";
  15.     my $remote_port = "1201";
  16.     my $count=0;
  17.     my $handle= IO::Socket::INET->new(   PeerAddr   =>   $remote_host, 
  18.                                        PeerPort   =>   $remote_port, 
  19.                                        Proto      =>   "tcp",
  20.                                         Type       =>   SOCK_STREAM
  21.                                    ) 
  22.     || die "Couldn't connect to $remote_host:$remote_port: \n"; 
  23.  
  24.     print STDERR "[Connected to $remote_host:$remote_port]\n";
  25.  
  26.  
  27.         DATA: {while(<$handle=1>)
  28.                 {
  29.                     for($count=0;$count<5;$count++)
  30.                     {
  31.                         my $send_data = strftime("::DATA::3847,%d.%m.%Y,%H:%M:%S,13.0149405,77.7736041,0,933.4,04A8,31,0 \n", gmtime);
  32.                         $handle-> send($send_data);
  33.                         $count=0;
  34.                         sleep(5);
  35.                     }
  36.                 }
  37.                 redo DATA;
  38.         }
  39. }
  40.  
the above script creates only one socket connection at a time........
what should be changed to create 5000 socket connections at the same time.
Jan 28 '10 #1
1 2568
chaarmann
785 Recognized Expert Contributor
Create 5000 pearl threads.
see:
http://www.xav.com/perl/lib/Pod/perlthrtut.html

each of these threads can start a single time your "sub repeat" function to create a socket connection. But because the thread creation itself also takes time, I would create all 5000 threads first and let them all sleep before they process this function until a special time is reached. For example if you start creating your threads at 10:00 o'clock and you know that the last thread will be created and up and running before maximum 10:03, then I would program all the threads to sleep and wake up at exactly 10:03 and execute your socket-creation function.
Jan 29 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2035
by: Lorax | last post by:
I'm on the IS team of a medium-sized non-profit with international reach. We're trying to make some decisions regarding our Web server and database server as we expand our web site to have more...
1
1998
by: Manish Gupta | last post by:
Hi there Can any one tell me the way to do load / stress testing of a client server based application. This is a Stand-alone application made using C#. Regards Manish
4
2200
by: Chris Gatto | last post by:
Hello, My organization is currently considering the purchase of a new intranet application server and we are looking for opinions from those who have been down this road before. In brief the...
2
9730
by: Curtis Justus | last post by:
Hi, I've been searching for solutions to two issues that are undoubtedly common to everybody. The first is how do my team and I adequately perform unit testing. The second is how can I measure...
0
1512
by: Chuck | last post by:
Sorry for the advertisement but I think this is something that people could actually use. I am creating a new product called Simple Load Testing and I thought I would see if anyone would be...
13
2972
by: Chris Bellini | last post by:
Greetings! I would like to use Server.Transfer to redirect users to a given page, while maintaining the state of form fields. This works fine on a single server. However, this will be...
2
6928
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
1183
by: =?Utf-8?B?TXlMYWJSdWJ5?= | last post by:
I am developing an application that will be able to be used offline from the SQL server and am trying to come up with a good way to do this. My thought at this moment is to basically work "offline"...
0
1579
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
I have a testing client program, the purpose is send a xml file to a server program, and the server return another xml message. So I wrote a testing server program the simple one and make sure the...
0
7264
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
7166
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
7386
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,...
1
7106
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7534
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5689
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,...
0
4749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3236
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.