Here we are in divination fields but i can share my little empiric experience: VPS and virtualization in general is intended to be economic (from the vendor point of view) not performant. The principle is optimizing dead times of machines and (hopefully) have peaks of usage not in concurrency. This means that a system intended to work constantly at high rate (as a big mailserver) is not a good candidate to be virtualized. More: i suspect that if CPU and RAM are well managed to accomplish these objective, not the same happens for the storage.

I use a little Perl program to distribute files over a bunch of machines: when i first introduced a virtualized OS in the group i noticed, often, a sensible and perceivible slower response from the virtualized OS respect the other, old pieces of iron.

Also empiraclly speaking, the storage is often the bottleneck of a VPS with hiccup like occurences.

That said here my speculation; i just guess that the Mojo::UserAgent->new is loading a lot of things, perl classes ie files. Thinking about an heavy module I have yet installed i just tested perl -MMoose -MDevel::Symdump -E "my $obj = Devel::Symdump->rnew('Moose'); say for $obj->packages()" and i got a screenfull of calsses ie files it can load (from the filesystem).

This can be the difference between the wget call and your Perl program.

You can test if theese assumption are correct setting up a little program where Mojo::UserAgent->new is called before doing your time calculation ( Time::Hires can be handy or a simply use of Benchmark ). Then time the $ua->get( $url ) part against the brutal wget syscall, better several times in a row.

If results are quite close and faster than your original program, then is the object creation the bottleneck. Interpreted languages have somehow their own level of virtualization, in a virtualized OS you add another layer of virtualization to the whole process. Generally speaking my opinion is that problems does'nt add, they multiply.

If this is your case and you need frequent call to such code better you set up a little demon that sat quite in the memory with his Mojo::UserAgent->new yet created and feed him with your URLs.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: Simple script goes from 2s to ~2mins when run on VPS by Discipulus
in thread Simple script goes from 2s to ~2mins when run on VPS by Anonymous Monk

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.