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

I'm doing a project for a group that's using IRC as the guts of a chatroom, and I'm load-testing the irc daemon with a Perl script. It uses Net::IRC to make one connection to the server, then blathers endlessly, every $X seconds, on a channel until it's stopped. (All machines concerned here are running Linux 2.2.)

I need to run arbitrary huge numbers of connections (500+ per bot machine would be nice), so I can find out what the ircd can take. Problem is, I can only run about 100 bot processes before the bot machine starts flailing against the open-files limit of the OS. What can I do about this problem, short of recompiling the kernel?

Are there any general things I should be doing to increase the efficiency of the bot? I'm avoiding threads because I've heard they're unstable in Perl. Thoughts?

Replies are listed 'Best First'.
Re: Net::IRC
by lindex (Friar) on Jul 21, 2000 at 05:30 UTC
    I my self run an IRC server and remember trying to run such
    a test with Net::IRC. If I remember correctly it doesnt
    allow you to have more than one Net::IRC handle. But you
    be able to do so by editing the module. I would suggest
    writing a Socket based tester or not even bother, If your using
    an ircd that is used by one of the big networks then you shouldn't
    have to bother



    lindex
    /****************************/ jason@gost.net, wh@ckz.org http://jason.gost.net /*****************************/
      Actually, you can run more than one connection with Net::IRC. Here is a minimal demonstration script:

      #!/usr/bin/perl use Net::IRC; use strict; my $server = "myserver"; my $irc = new Net::IRC; my $conn1 = $irc->newconn(Nick => "test1", Server => $server, Port => 6667); my $conn2 = $irc->newconn(Nick => "test2", Server => $server, Port => 6667); $conn1->add_global_handler('msg', \&on_msg); $conn2->add_global_handler('msg', \&on_msg); $irc->start; sub on_msg { my ($self, $event) = @_; my $who = $event->nick; $self->privmsg($who, "hello, $who!!"); }
      Send a message to either of the bots, and they'll reply. You can also add different handlers for each connection, and it'll do the right thing.

      However, I don't know if this gets you a win or a lose as to open file handles overall...

      Alan

        Iam humbled yet agian :) get my vote.


        lindex
        /****************************/ jason@gost.net, wh@ckz.org http://jason.gost.net /*****************************/
RE: Net::IRC, load testing, and threads
by ferrency (Deacon) on Jul 20, 2000 at 23:58 UTC
    You could check out what files your bot is holding open, using fstat. Get rid of any that aren't Absolutely Necessary. I'm not familiar with the innards of Net::IRC, but you might be able to reduce open file resource use by creating multiple Net::IRC's in one bot, and using a select() over all of them. This could complicate your bot quickly if it does anything besides randomly talk occasionally, though.

    Alan

    ps I assume you're on some UNIX-like OS since "recompiling the kernel" was mentioned as an option...