Here's a simple script that executes some SQL as often as possible. I've used it to e.g. measure the overhead of Java stored procedures in Sybase and stuff like that, but I think any SQL statement should work as long as it doesn't return billions and billions of rows. Check out the DBD::Oracle docs on how to form the connect string.

Start as many instances if you need to simulate many connections.

#!/usr/bin/perl -w $|++; use strict; use Time::HiRes qw/time/; use DBI; use DBD::Sybase; my ($dbi, $user, $pass, $sql, $logEvery) = @ARGV or die(q{ Syntax: call_sp connect_string user password sql Example: call_sp dbi:Sybase:server=DEV_DB_01_DS;database=test_performance sa PA +SSWORD "exec jpl_test" }); $logEvery ||= 200; my $dbh = DBI->connect( $dbi, $user, $pass, { RaiseError => 1, PrintError => 0 } ); my $sth = $dbh->prepare($sql); my @aOldAverage; my $maxOldAverage = 10; my $no = 0; my $timeLatest = time(); while(1) { if($no++ > $logEvery) { my $timeNow = time(); my $timeDuration = $timeNow - $timeLatest; my $freq = sprintf("%0.2d", $no / ($timeDuration || 1)); $timeLatest = $timeNow; $no = 0; push(@aOldAverage, $freq); if(@aOldAverage > $maxOldAverage) { shift(@aOldAverage); } my $oldCount = @aOldAverage; my $sum = 0; $sum += $_ for(@aOldAverage); my $avg = sprintf("%0.2d", $sum / $oldCount); print localtime() . ": $freq / sec ($avg/sec for the last $old +Count readings)\n"; } eval { $sth->execute(); }; if($@) { warn("$@\n"); $sth = $dbh->prepare($sql); next; } $sth->fetchall_arrayref; $sth->finish; } __END__

If you need more complex behaviour, you may need to develop a robot (bot) user that simulates typical behaviour with a proper mix of idle time, selects, inserts, etc. If most of the time is spent idle, look into POE (or something like that) to run hundreds or thousands of users in a single process. Start more processes until the machine can't handle any more, then add extra machines.

/J


In reply to Re: Database Workload Simulator by jplindstrom
in thread Database Workload Simulator by DrAxeman

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.