Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Microservices
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hans Hasselberg
September 05, 2013
Programming
320
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Microservices
Hans Hasselberg
September 05, 2013
More Decks by Hans Hasselberg
See All by Hans Hasselberg
Introduction to HashiCorp Waypoint
i0rek
0
200
Autoconfiguration of Consul Clients
i0rek
0
230
Einführung in HashiCorp Boundary
i0rek
0
130
Provisioning for Dummies
i0rek
0
310
Polyphasic Sleep & Typhoeus
i0rek
0
110
Other Decks in Programming
See All in Programming
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
240
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
520
CSC307 Lecture 17
javiergs
PRO
0
320
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.3k
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.3k
Vite+ Unified Toolchain for the Web
naokihaba
0
240
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
170
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
710
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
500
Oxlintのカスタムルールの現況
syumai
6
1.1k
AIで効率化できた業務・日常
ochtum
0
120
Featured
See All Featured
New Earth Scene 8
popppiees
3
2.3k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
720
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
So, you think you're a good person
axbom
PRO
2
2.1k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
220
The Cost Of JavaScript in 2023
addyosmani
55
10k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
HDC tutorial
michielstock
2
700
How to Talk to Developers About Accessibility
jct
2
230
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
430
Transcript
MicroServices Friday, September 6, 13
0 500 1000 1500 2000 req/sec 1752 177 Service Microservice
Friday, September 6, 13
i0rek Friday, September 6, 13
Disclaimer • Benchmarking is hard • Questions at the end
Friday, September 6, 13
Fred George Friday, September 6, 13
Wunderpay Friday, September 6, 13
Wunderpay • Create Subscriptions Friday, September 6, 13
Wunderpay • Create Subscriptions • Get subscription for a user
Friday, September 6, 13
Wunderpay • Create Subscriptions • Get subscription for a user
Friday, September 6, 13
Rails 1 # app/controllers/s_controller.rb 2 class SController < ApplicationController 3
def show 4 if subscription = current_user.subscription 5 render json: subscription.as_json 6 else 7 render json: {} 8 end 9 end 10 end Friday, September 6, 13
AB Rails $ ab -n 1000 http://127.0.0.1/user/123A Requests per second:
177.88 [#/sec] Time per request: 5.622 [ms] Friday, September 6, 13
Rails - Y U SLOW?? 1 # app/controllers/s_controller.rb 2 class
SController < ApplicationController 3 def show 4 if subscription = current_user.subscription 5 render json: subscription.as_json 6 else 7 render json: {} 8 end 9 end 10 end Friday, September 6, 13
Rails - Y U SLOW?? • Assumption: DB is the
limiting factor Friday, September 6, 13
Rack Part 1 1 require 'sequel' 2 class Database 3
def self.connection 4 @connection ||= Sequel.connect( 5 'mysql: 6 //root@localhost/wunderpay_development' 7 ) 8 end 9 end 10 class Subscription 11 def self.exists_for(user_id) 12 Database.connection[ 13 "SELECT 1 14 FROM Subscriptions 15 WHERE user_id = '#{user_id}' 16 LIMIT 1" 17 ].count > 0 18 end 19 end Friday, September 6, 13
Rack Part 2 1 class MyApp 2 def call(env) 3
if env['REQUEST_PATH'] =~ /user\/(\w*)/ 4 unless Subscription.exists_for($1) 5 [200, {}, ["{}\n"]] 6 else 7 [ 301, 8 {"Location" => "http://wunderpay.de"}, 9 ["\n"] 10 ] 11 end 12 end 13 end 14 end Friday, September 6, 13
AB Rack $ ab -n 1000 http://127.0.0.1/user/123A Requests per second:
856.72 [#/sec] Time per request: 1.167 [ms] Friday, September 6, 13
Rack Y U SO FAST?? • Assumption was WRONG •
5times faster than Rails Friday, September 6, 13
Rack MicroService 1 class MyApp 2 def call(env) 3 if
env['REQUEST_PATH'] =~ /user\/(\w*)/ 4 unless Subscription.exists_for($1) 5 [200, {}, ["{}\n"]] 6 else 7 [ 301, 8 {"Location" => "http://wunderpay.de"}, 9 ["\n"] 10 ] 11 end 12 end 13 end 14 end Friday, September 6, 13
Rack MicroService • Transparent • Throw away • Simple.Simple.Simple Friday,
September 6, 13
Rack MicroService Friday, September 6, 13
How fast can we get? Friday, September 6, 13
Nginx & Lua Friday, September 6, 13
Nginx & Lua Part 1 1 worker_processes 1; 2 error_log
logs/error.log; 3 events { 4 worker_connections 1024; 5 } 6 http { 7 server { 8 listen 8080; 9 location ~ /user/(\w*) { 10 set $user_id $1; 11 content_by_lua ''; 12 } 13 } 14 } Friday, September 6, 13
Nginx & Lua Part 2 1 local mysql = require
"resty.mysql" 2 local db, err = mysql:new() 3 db:set_timeout(1000) 4 5 local ok, err, errno, sqlstate = db:connect{ 6 host = "127.0.0.1", 7 port = 3306, 8 database = "wunderpay_development", 9 user = "root" 10 } 11 12 res, err, errno, sqlstate = db:query( 13 "SELECT 1 " .. 14 "FROM subscriptions " .. 15 "WHERE user_id = \'"..ngx.var.user_id.. 16 "\'" 17 ) 18 if next(res) == nil then 19 ngx.say("{}") 20 else 21 ngx.redirect("http://wunderpay.de") 22 end Friday, September 6, 13
AB Nginx & Lua $ ab -n 1000 http://127.0.0.1/user/123A Requests
per second: 1752.04 [#/sec] Time per request: 0.571 [ms] Friday, September 6, 13
Resources Friday, September 6, 13
Resources 1.Rails 2.Rack 3.Nginx & Lua Friday, September 6, 13
Q & A Friday, September 6, 13