Brooklyn is a small (~300 LOC) rack-based application builder. Was made as proof of concept that fast and small code can still work.
Presented as RubyConf Argentina Lighting talk.
Brooklyn, NYSmall Ruby web toolgithub.com/luislavena/brooklyn
View Slide
Luis LavenaWork: area17.comTwitter: @luislavenaGitHub: luislavena
ProblemCreate minimal service (just JSON)In RubyRack compatible
DramaNeed for speed (fewer allocs/req)Less Ruby magicNo backward compatibilitySmall codebaseNo code is faster than no code
GoalUnderstand what is going on
Reference: Rackclass HelloWorlddef call(env)[200,{"Content-Type" => "text/html"},["Hello World!"]]endendrun HelloWorld.new
Minimal DSL (Sinatra)require "sinatra/base"class HelloWorld < Sinatra::Baseget "/" do"Hello World!"endendrun HelloWorld
Brooklynrequire "brooklyn"class HelloWorld < Brooklyn::Appget "/" do"Hello World!"endendrun HelloWorld.new
CodebaseSinatra: 2035 lines (1738 sloc, 1 file)Brooklyn: 217 lines (165 sloc, 7 files)
PerformanceRack: 7637 req/sec (1.0x)Sinatra: 2712 req/sec (0.35x)Brooklyn: 5827 req/sec (0.76x)github.com/luislavena/bench-micro
AgainRack-powered (use middlewares)No code is faster than no codeLess ruby magicCode you can understand (in 10 minutes)
Thanks!github.com/luislavena/brooklyn