Hello,

Let's say I'm running the following snippet in apache2/mod_perl, all with
the default configuration:

#========================================#
#!/usr/bin/perl

use strict;
use CGI qw(:standard);
use MogileFS::Client;

my $mogfs = MogileFS::Client->new(domain => 'testdomain',
                          hosts  => [ '192.168.1.1:6001', '192.168.1.2:6001'
],
                          root   => '/var/mogdata',);
die "Unable to initialize MogileFS object.\n" unless $mogfs;

#get the hash of the url
my $imagehash = param('imagehash') || 0;

#get the requested image file
my $image = $mogfs->get_file_data($imagehash);

#now we got the content, i.e. we will probably cache it here using memcached

#just serve the image directly for now
print "Content-type: image/jpeg\n\n";
print $$image;
#========================================#

What I want to know is, what is the most optimal way to use the $mogfs
object?

Or:
-Does it get initialised everytime a request is made? Is that okay
performance wise? If not, can it be made global in a way?
-How does wrapping the communication to the mogilefs system in
apache2/mod_perl affect the performance in general? I reckon that
apache2/mod_perl ought to be optimally configured, like max
threads/connections etc.

I would be glad to get a few pointers on these ones :)

Reply via email to