Skip to content

Instantly share code, notes, and snippets.

@jodosha
Created August 6, 2014 16:33
Show Gist options
  • Save jodosha/ff584e0e3636fc5ece7f to your computer and use it in GitHub Desktop.
Save jodosha/ff584e0e3636fc5ece7f to your computer and use it in GitHub Desktop.
Lotus w/ Rack::Protection

Lotus

Router                 (router.ru)                 7036.45 req/s
Action                 (action.ru)                 6225.49 req/s
Tiny                   (tiny.ru)                   6631.06 req/s
Tiny Action            (tiny_action.ru)            4948.72 req/s
View                   (view.ru)                   4310.54 req/s
Template               (template.ru)               4175.52 req/s
Template Interpolation (template_interpolation.ru) 4075.00 req/s

Lotus + Rack::Protection

Router                 (router_protection.ru)                 3224.94 req/s
Action                 (action_protection.ru)                 2926.06 req/s
Tiny                   (tiny_protection.ru)                   2224.42 req/s
Tiny Action            (tiny_action_protection.ru)            1206.49 req/s
View                   (view_protection.ru)                   1216.94 req/s
Template               (template_protection.ru)               1207.28 req/s
Template Interpolation (template_interpolation_protection.ru) 1213.31 req/s

Installation

bundle install

Start the server

bundle exec puma -e production -t 16:16 <file>.ru

Run the benchmark

wrk -t 2 http://localhost:9292/
require 'lotus/controller'
class Greet
include Lotus::Action
def call(params)
self.body = 'Hello World!'
end
end
run Greet.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.59ms 16.48ms 75.04ms 93.57%
Req/Sec 3.29k 0.95k 4.44k 90.15%
62255 requests in 10.00s, 5.40MB read
Requests/sec: 6225.49
Transfer/sec: 553.29KB
require 'lotus/controller'
require 'rack-protection'
class Greet
include Lotus::Action
def call(params)
self.body = 'Hello World!'
end
end
use Rack::Session::Cookie, secret: 'abc'
use Rack::Protection
run Greet.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.94ms 12.82ms 69.29ms 95.80%
Req/Sec 1.54k 381.23 2.22k 88.89%
29260 requests in 10.00s, 17.75MB read
Requests/sec: 2926.06
Transfer/sec: 1.78MB
source 'https://rubygems.org'
gem 'lotusrb', require: false, github: 'lotus/lotus'
gem 'rack-protection', require: false
gem 'puma'
Hello <%= planet %>!
require 'lotus/router'
run Lotus::Router.new {
get '/', to: ->(env) { [200, {}, ['Hello World!']] }
}
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.12ms 12.86ms 66.39ms 94.85%
Req/Sec 3.74k 0.98k 5.00k 90.96%
70377 requests in 10.00s, 3.42MB read
Requests/sec: 7036.45
Transfer/sec: 350.46KB
require 'lotus/router'
require 'rack-protection'
use Rack::Session::Cookie, secret: 'abc'
use Rack::Protection
run Lotus::Router.new {
get '/', to: ->(env) { [200, {}, ['Hello World!']] }
}
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.67ms 12.82ms 70.21ms 95.72%
Req/Sec 1.70k 427.44 2.44k 89.69%
32249 requests in 10.00s, 18.33MB read
Requests/sec: 3224.94
Transfer/sec: 1.83MB
require 'lotus'
module OneFile
class Application < Lotus::Application
configure do
templates __dir__
routes do
get '/', to: 'home#index'
end
end
load!
end
module Controllers
module Home
include OneFile::Controller
action 'Index' do
def call(params)
end
end
end
end
module Views
module Home
class Index
include Lotus::View
template 'home/index'
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.06ms 9.36ms 56.97ms 96.44%
Req/Sec 2.21k 496.05 3.11k 91.24%
41755 requests in 10.00s, 3.07MB read
Requests/sec: 4175.52
Transfer/sec: 314.00KB
require 'lotus'
module OneFile
class Application < Lotus::Application
configure do
templates __dir__
routes do
get '/', to: 'home#index'
end
end
load!
end
module Controllers
module Home
include OneFile::Controller
action 'Index' do
expose :planet
def call(params)
@planet = 'World'
end
end
end
end
module Views
module Home
class Index
include Lotus::View
template 'home/interpolation'
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.33ms 10.40ms 63.20ms 96.46%
Req/Sec 2.16k 485.51 3.00k 90.12%
40750 requests in 10.00s, 2.99MB read
Requests/sec: 4075.00
Transfer/sec: 306.43KB
require 'lotus'
require 'rack-protection'
module OneFile
class Application < Lotus::Application
configure do
templates __dir__
routes do
get '/', to: 'home#index'
end
middleware.use Rack::Session::Cookie, secret: 'abc'
middleware.use Rack::Protection
end
load!
end
module Controllers
module Home
include OneFile::Controller
action 'Index' do
expose :planet
def call(params)
@planet = 'World'
end
end
end
end
module Views
module Home
class Index
include Lotus::View
template 'home/interpolation'
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 14.77ms 26.87ms 121.90ms 93.51%
Req/Sec 618.21 187.35 0.92k 86.10%
12133 requests in 10.00s, 13.84MB read
Requests/sec: 1213.31
Transfer/sec: 1.38MB
require 'lotus'
require 'rack-protection'
module OneFile
class Application < Lotus::Application
configure do
templates __dir__
routes do
get '/', to: 'home#index'
end
middleware.use Rack::Session::Cookie, secret: 'abc'
middleware.use Rack::Protection
end
load!
end
module Controllers
module Home
include OneFile::Controller
action 'Index' do
def call(params)
end
end
end
end
module Views
module Home
class Index
include Lotus::View
template 'home/index'
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 13.86ms 23.29ms 106.65ms 93.54%
Req/Sec 614.77 183.41 0.92k 85.60%
12074 requests in 10.00s, 13.77MB read
Requests/sec: 1207.28
Transfer/sec: 1.38MB
require 'lotus'
module OneFile
class Application < Lotus::Application
configure do
routes do
get '/', to: ->(env) {[200, {}, ['Hello World!']]}
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.86ms 14.94ms 73.12ms 94.21%
Req/Sec 3.53k 0.97k 4.67k 90.74%
66307 requests in 10.00s, 3.23MB read
Requests/sec: 6631.06
Transfer/sec: 330.27KB
require 'lotus'
module OneFile
class Application < Lotus::Application
configure do
routes do
get '/', to: 'home#index'
end
end
load!
end
module Controllers
module Home
include OneFile::Controller
action 'Index' do
def call(params)
self.body = 'Hello World!'
end
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 6.65ms 18.30ms 80.08ms 93.06%
Req/Sec 2.62k 771.10 3.67k 89.57%
49486 requests in 10.00s, 3.59MB read
Requests/sec: 4948.72
Transfer/sec: 367.33KB
require 'lotus'
require 'rack-protection'
module OneFile
class Application < Lotus::Application
configure do
routes do
get '/', to: 'home#index'
end
middleware.use Rack::Session::Cookie, secret: 'abc'
middleware.use Rack::Protection
end
load!
end
module Controllers
module Home
include OneFile::Controller
action 'Index' do
def call(params)
self.body = 'Hello World!'
end
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 13.74ms 23.54ms 109.26ms 93.98%
Req/Sec 614.24 182.12 0.96k 84.73%
12066 requests in 10.00s, 13.75MB read
Requests/sec: 1206.49
Transfer/sec: 1.38MB
require 'lotus'
require 'rack-protection'
module OneFile
class Application < Lotus::Application
configure do
routes do
get '/', to: ->(env) {[200, {}, ['Hello World!']]}
end
middleware.use Rack::Session::Cookie, secret: 'abc'
middleware.use Rack::Protection
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 9.94ms 22.28ms 99.29ms 93.81%
Req/Sec 1.16k 344.77 1.80k 88.19%
22244 requests in 10.00s, 12.64MB read
Requests/sec: 2224.42
Transfer/sec: 1.26MB
require 'lotus'
module OneFile
class Application < Lotus::Application
configure do
routes do
get '/', to: 'home#index'
end
end
load!
end
module Controllers
module Home
include OneFile::Controller
action 'Index' do
def call(params)
end
end
end
end
module Views
module Home
class Index
include Lotus::View
def render
'Hello World!'
end
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 3.89ms 9.45ms 59.32ms 97.02%
Req/Sec 2.28k 513.90 3.22k 89.18%
43104 requests in 10.00s, 3.12MB read
Requests/sec: 4310.54
Transfer/sec: 319.93KB
require 'lotus'
require 'rack-protection'
module OneFile
class Application < Lotus::Application
configure do
routes do
get '/', to: 'home#index'
end
middleware.use Rack::Session::Cookie, secret: 'abc'
middleware.use Rack::Protection
end
load!
end
module Controllers
module Home
include OneFile::Controller
action 'Index' do
def call(params)
end
end
end
end
module Views
module Home
class Index
include Lotus::View
def render
'Hello World!'
end
end
end
end
end
run OneFile::Application.new
__END__
Running 10s test @ http://localhost:9292/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 13.93ms 23.73ms 107.66ms 93.54%
Req/Sec 619.97 188.11 0.89k 85.83%
12170 requests in 10.00s, 13.88MB read
Requests/sec: 1216.94
Transfer/sec: 1.39MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment