thanx to saxman!
i modified the
deamon.pl to:
#!/usr/bin/perl -w
use strict;
use warnings;
use IO::Socket;
use ResourcePool;
use ResourcePool::Factory::DBI;
use ResourcePool::Command::DBI::Execute;
# Initialize parameter ------------------------------------------------
my $port = 6000;
my $dsn = "DBI:mysql:
DBname;
DBserver;3306";
my $username = "xxx";
my $passwd = "yyy";
# Initialize Ressource ------------------------------------------------
my $factory = ResourcePool::Factory::DBI->new(
$dsn,
$username,
$passwd);
my $pool = ResourcePool->new($factory, MaxTry => 3);
# Initialize Socket ------------------------------------------------
my $sock = new IO::Socket::INET(
LocalHost => 'localhost',
LocalPort => $port,
Proto => 'tcp',
Listen => SOMAXCONN,
Reuse => 1);
$sock or die "no socket :$!";
my($new_sock, $c_addr, $buf);
while(1==1)
{
while (($new_sock, $c_addr) = $sock->accept())
{
my ($client_port, $c_ip) =sockaddr_in($c_addr);
my $client_ipnum = inet_ntoa($c_ip);
my $client_host =gethostbyaddr($c_ip, AF_INET);
my $code = '';
while (defined ($buf = <$new_sock>))
{
$code .= $buf;
}
my $cmd = ResourcePool::Command::DBI::Execute->new();
$pool->execute($cmd, $code);
}
}
exit;
__END__
Also i used a skript which forked 100 instances of the
client.pl each pushing a ~7k INSERT statement to the
deamon.pl; this worked fine - all 7000 entries arrived at the DB server and were processed.
it took around 5 secs for the database to execute all statements. that brought me to the following problem:
if there are a lot of client scripts running, the queue will fill up and the clients will keep waiting for the deamon if its queue is full. so the traffic-problem i tried to solve just shiftet to a local connection bottleneck... :-(
is there a possibility to do the socket stuff multithreaded?? each thread with its own socket but using the same sql-queue???
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.