I have seen mentions (which sounded like unsubstantiated opinions, and dated ones at that) that Embperl is the fastest Perl web framework.
I was wondering if there's a consensus on the relative speed of the major stable Perl web frameworks, or ideally, some sort of fact-based performance comparisons between implementations of the same sample webapps, or individual functionalities (e.g. session handling or form data processing), etc...?
UPDATE: This question is specifically about the speed comparison of different frameworks, executing identical/equivalent tasks. I appreciate the good intentions, but I already know that speed is not the only criteria I should be looking at. I wasn't asking for philosophical advice. And believe it or not, being frameworks, you CAN actually compare their speed on an apple-to-apple basis by running identically purposed tasks/code/apps on them (e.g. render a given form with a given set of templated inserts etc...), even if the full functionality of each framework is not 100% the same.
Which is the fastest web framework? In benchmark tests, Spring has shown to be the fastest back-end web framework currently available to developers.
If you already have a CPAN client configured, you can install Mojolicious with the regular command cpan Mojolicious. Otherwise on Linux systems you can first install cpanminus by typing curl -L http://cpanmin.us | perl - App::cpanminus. Then you can install Mojolicious by typing cpanm Mojolicious.
I don't want to go into the interpretation discussion (for most real world scenarios these overheads have no impact at all) - but here are my tests:
zby@zby:~/progs/bench$ cat app.psgi
sub {
my ( $env ) = @_;
return [
200,
[ 'Content-Type' => 'text/text' ],
[ 'Hello World' ]
];
}
zby@zby:~/progs/bench$ plackup
HTTP::Server::PSGI: Accepting connections at http://0:5000/
With simple ab -n 10000
I get
Requests per second: 2168.05 [#/sec] (mean)
zby@zby:~/progs/bench$ cat dancer.pl
#!/usr/bin/perl
use Dancer;
get '/' => sub {
return "Why, hello there";
};
dance;
zby@zby:~/progs/bench$ perl dancer.pl
>> Dancer server 1950 listening on http://0.0.0.0:3000
== Entering the development dance floor ...
With similar ab test I get
Requests per second: 1570.49 [#/sec] (mean)
zby@zby:~/progs/bench$ cat mojo.pl
# Using Mojolicious::Lite will enable "strict" and "warnings"
use Mojolicious::Lite;
# Route with placeholder
get '/' => sub {
my $self = shift;
$self->render(text => "Hello!");
};
# Start the Mojolicious command system
app->start;
zby@zby:~/progs/bench$ perl mojo.pl daemon
Sat Jan 22 20:37:01 2011 info Mojo::Server::Daemon:320 [2315]: Server listening (http://*:3000)
Server available at http://*:3000.
Result: Requests per second: 763.72 [#/sec] (mean)
Unfortunately the code is much too long to be presented here in its entirety, but the Root controller contains:
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
# Hello World
$c->response->body( 'Hello World' );
}
The result is:
Requests per second: 727.93 [#/sec] (mean)
zby@zby:~/progs/bench$ cat webnano.psgi
{
package MyApp;
use base 'WebNano';
1;
}
{
package MyApp::Controller;
use base 'WebNano::Controller';
sub index_action {
my $self = shift;
return 'This is my home';
}
1;
}
MyApp->new()->psgi_callback;
zby@zby:~/progs/bench$ plackup webnano.psgi
HTTP::Server::PSGI: Accepting connections at http://0:5000/
And the result:
Requests per second: 1884.54 [#/sec] (mean)
This will change after some more features are added.
Here is one comparison between perl frameworks, in terms of speed (startup) and memory consumed by framework itself. It is a bit old (2008), so it does not compare new stuff like Plack.
http://mark.stosberg.com/blog/2008/11/startup-benchmarks-for-mojo-catalyst-titanium-httpengine-and-cgiapplication.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With