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
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
140
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
330
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
110
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
750
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
520
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2k
Agentic UI
manfredsteyer
PRO
0
150
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
730
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
240
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
130
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
190
Featured
See All Featured
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
380
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Are puppies a ranking factor?
jonoalderson
1
3.5k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
250
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
160
For a Future-Friendly Web
brad_frost
183
10k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
170
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
160
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.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