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
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
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.4k
5分で問診!Composer セキュリティ健康診断
codmoninc
0
700
Build-to-own AI: Agentic Development for Humans
inesmontani
PRO
0
120
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
560
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
120
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
2.7k
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
480
テーブルをDELETEした
yuzneri
0
120
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
190
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
230
数百円から始めるRuby電子工作
tarosay
0
120
継続モナドとリアクティブプログラミング
yukikurage
3
660
Featured
See All Featured
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
400
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Building the Perfect Custom Keyboard
takai
2
820
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
390
A Modern Web Designer's Workflow
chriscoyier
698
190k
How to train your dragon (web standard)
notwaldorf
97
6.7k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.2k
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