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*
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |