-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from naturalist/master
Added the Perl Kelp micro framework
- Loading branch information
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Setup | ||
|
||
* Perl 5.10+ | ||
* MySQL 5.5 | ||
* Wrk 2.0 | ||
|
||
# Requirements | ||
|
||
* Kelp | ||
* DBD::mysql | ||
* Starman (if using Starman as web server) | ||
* Plack (for plackup) | ||
* nginx (if you want to front Dancer with nginx, nginx.conf provided) | ||
|
||
# Deployment | ||
|
||
Something along the lines of | ||
|
||
plackup -E production -s Starman --workers=2 -l /tmp/frameworks-benchmark.sock -a ./app.pl | ||
|
||
if you want to front it with nginx, otherwise | ||
|
||
plackup -E production -s Starman --port=8080 --workers=2 -a ./app.pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env perl | ||
use Kelp::Less; | ||
use DBI; | ||
|
||
attr dbh => sub { | ||
my $database = 'test'; | ||
my $host = 'ip-10-34-150-134.eu-west-1.compute.internal'; | ||
my $dsn = 'dbi:mysql:database=$database;host=$host;port=3306'; | ||
DBI->connect( $dsn, 'root', '', {} ); | ||
}; | ||
|
||
get '/json' => sub { | ||
{ message => 'Hello, World!' } | ||
}; | ||
|
||
get '/db' => sub { | ||
my $self = shift; | ||
my $queries = param->{queries} || 1; | ||
my @response; | ||
for( 1 .. $queries ) { | ||
my $id = int rand 10000 + 1; | ||
if ( my $row = $self->dbh->quick_select( 'world', { id => $id } ) ) { | ||
push @response, { id => $id, randomNumber => $row->{randomnumber} }; | ||
} | ||
} | ||
{ \@response } | ||
}; | ||
|
||
run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
user www; | ||
|
||
worker_processes 2; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
output_buffers 1 32k; | ||
postpone_output 1460; | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
|
||
tcp_nodelay on; | ||
|
||
upstream backendurl { | ||
server unix:/tmp/frameworks-benchmark.sock; | ||
} | ||
|
||
server { | ||
listen 8888; | ||
server_name localhost; | ||
|
||
location / { | ||
try_files $uri @proxy; | ||
access_log off; | ||
expires max; | ||
} | ||
|
||
location @proxy { | ||
proxy_set_header Host $http_host; | ||
proxy_pass http://backendurl; | ||
} | ||
} | ||
} |