miyagawa / Starman

Starman is a high-performance preforking Perl PSGI web server
http://search.cpan.org/dist/Starman
Other
287 stars 84 forks source link

NAME

Starman - High-performance preforking PSGI/Plack web server

SYNOPSIS

# Run app.psgi with the default settings
> starman

# run with Server::Starter
> start_server --port 127.0.0.1:80 -- starman --workers 32 myapp.psgi

# UNIX domain sockets
> starman --listen /tmp/starman.sock

Read more options and configurations by running `perldoc starman` (lower-case s).

DESCRIPTION

Starman is a PSGI perl web server that has unique features such as:

PERFORMANCE

Here's a simple benchmark using Hello.psgi.

-- server: Starman (workers=10)
Requests per second:    6849.16 [#/sec] (mean)
-- server: Twiggy
Requests per second:    3911.78 [#/sec] (mean)
-- server: AnyEvent::HTTPD
Requests per second:    2738.49 [#/sec] (mean)
-- server: HTTP::Server::PSGI
Requests per second:    2218.16 [#/sec] (mean)
-- server: HTTP::Server::PSGI (workers=10)
Requests per second:    2792.99 [#/sec] (mean)
-- server: HTTP::Server::Simple
Requests per second:    1435.50 [#/sec] (mean)
-- server: Corona
Requests per second:    2332.00 [#/sec] (mean)
-- server: POE
Requests per second:    503.59 [#/sec] (mean)

This benchmark was processed with ab -c 10 -t 1 -k on MacBook Pro 13" late 2009 model on Mac OS X 10.6.2 with perl 5.10.0. YMMV.

NOTES

Because Starman runs as a preforking model, it is not recommended to serve the requests directly from the internet, especially when slow requesting clients are taken into consideration. It is suggested to put Starman workers behind the frontend servers such as nginx, and use HTTP proxy with TCP or UNIX sockets.

PSGI EXTENSIONS

psgix.informational

Starman exposes a callback named psgix.informational that can be used for sending an informational response. The callback accepts two arguments, the first argument being the status code and the second being an arrayref of the headers to be sent. Example below sends an 103 Early Hints response before processing the request to build a final response.

sub {
    my $env = shift;

    $env->{'psgix.informational'}->( 103, [
        "Link" => "</style.css>; rel=preload"
    ] );

    my $rest = ...
    $resp;
}

AUTHOR

Tatsuhiko Miyagawa miyagawa@bulknews.net

Andy Grundman wrote Catalyst::Engine::HTTP::Prefork, which this module is heavily based on.

Kazuho Oku wrote Net::Server::SS::PreFork that makes it easy to add Server::Starter support to this software.

The psgix.informational callback comes from Starlet by Kazuho Oku.

COPYRIGHT

Tatsuhiko Miyagawa, 2010-

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Plack Catalyst::Engine::HTTP::Prefork Net::Server::PreFork