Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a UDP server written in perl, I am trying to see the maximum load it can handle. I use a udp sender that reads a file and sends the message to the server , the server prints that message to the STDOUT.

When I send a burst of messages to the server I see some packets being dropped (netstat -su), I wanted to see how it works when I do the same in C and used This C program . When I run the C version it does not drop any message.


I thought the Perl socket used the underlying C libraries, So why does the perl version drop so many packets while the C version does not. Is there any way to make the perl version faster ?.


Here is the Perl version (example from Net::Server)
#!/usr/bin/perl =head1 NAME udp_server.pl - Simple sample udp echo server =head1 SERVER SYNOPSIS perl udp_server.pl --log_level 3 # default is to not background =cut package MyUDPD; use strict; use warnings; use Data::Dumper; my $port =32000; my $host = '0.0.0.0'; my $recv_length = 8192; # packet size use base qw(Net::Server::PreFork); ### run the server MyUDPD->run( port => "$host:$port/udp", min_servers => 10, ); exit; sub configure_hook { my $self = shift; ### change the packet len? $self->{server}->{udp_recv_len} = $recv_length; # default is 4096 } sub process_request { my $self = shift; my $prop = $self->{'server'}; print STDOUT $prop->{'udp_data'}; return; }
Thanks

Replies are listed 'Best First'.
Re: Perl Socket Speed
by bluescreen (Friar) on Jun 28, 2010 at 23:50 UTC

    Did you try a bare udp socket server like the one mentioned here?

    I'm wondering how max_servers and max_requests defaults are playing here, in any case try to reduce increment those values and see if that affects the drop rate measured

    What are you using to stress your server? nc or another client written in Perl/C ?

      Its another client written in perl, I will check the max_servers and max_requests. Thanks.