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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Hans Hasselberg
September 05, 2013
Programming
330
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
210
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
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
750
Foundation Models frameworkで画像分析
ryodeveloper
1
210
FDEが実現するAI駆動経営の現在地
gonta
2
240
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
190
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.3k
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
500
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
130
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
290
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
4
310
コーディングルールの鮮度を保ちたい for SRE NEXT 2026 / keep-fresh-go-internal-conventions-sre-next-2026
handlename
0
160
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
630
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
190
Featured
See All Featured
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
600
Being A Developer After 40
akosma
91
590k
Become a Pro
speakerdeck
PRO
31
6k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
240
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
Are puppies a ranking factor?
jonoalderson
1
3.7k
Odyssey Design
rkendrick25
PRO
2
740
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
340
Game over? The fight for quality and originality in the time of robots
wayneb77
1
230
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