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
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
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
680
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.8k
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
130
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.6k
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
210
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
140
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
250
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.7k
AIエージェントで 変わるAndroid開発環境
takahirom
1
300
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
7.2k
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
340
Featured
See All Featured
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
220
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
440
Game over? The fight for quality and originality in the time of robots
wayneb77
1
220
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
From π to Pie charts
rasagy
0
230
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
580
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
310
Claude Code のすすめ
schroneko
67
230k
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