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
Let's Scale Ruby Applications with Love
Search
Bernie Chiu
July 26, 2019
Technology
4
880
Let's Scale Ruby Applications with Love
Bernie Chiu
July 26, 2019
Tweet
Share
Other Decks in Technology
See All in Technology
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
Storybook との上手な向き合い方を考える
re_taro
4
610
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
200
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
310
LINEヤフーにおけるPrerender技術の導入とその効果
narirou
1
120
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
490
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
710
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.7k
複雑なState管理からの脱却
sansantech
PRO
1
160
"とにかくやってみる"で始めるAWS Security Hub
maimyyym
2
100
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
GitHub's CSS Performance
jonrohan
1030
460k
Gamification - CAS2011
davidbonilla
80
5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
What's new in Ruby 2.0
geeforr
343
31k
Transcript
LET’S SCALE RUBY APPLICATIONS WITH ❤
WHO AM I ?
None
GitHub: berniechiu Twitter: berniechiu_tw Software Engineer @
OVERVIEW • Ruby and API • Ruby and Database •
Ruby and Network • Ruby and… just Ruby
WHAT MATTERS?
AVERAGES?
–DHH 「1000 requests that return in 5ms, and 200 requests
taking 2,000 ms, still get a respectable 170ms average」
Only Very Happy & Very Unhappy Credit from : https://www.youtube.com/watch?v=VPYP7oJJPdo
TUNE YOUR DESIRED METRICS
SO WHAT MATTERS? • Popular endpoints • Slow response times
None
RUBY WEB + API
RESTFUL ENTHUSIASM
None
None
None
EVEN MORE DATA?
• github.com/zdennis/activerecord-import • github.com/jamis/bulk_insert
ALWAYS KNOW WHAT RUNS UNDER RUBY
RUBY DATABASE + PAGINATIONS
None
Performance Impact
For example - Kaminari
None
None
None
KEEPING USER NAVIGATIONS INTACT?
Prefetched Count
None
None
None
ITERATIONS FROM ACTIVERECORD
FIND EACH FIND IN BATCHES • Memory saving • Fetch
limited rows on each batch/iteration • Won’t lock the whole table
BUT!
WORKING WITH UUID?
None
UUID V4 IS SORTABLE?
Credit from: https://www.postgresql.org/docs/9.6/uuid-ossp.html
Credit From: GitLab CE Custom Implementations
SPEED REGAIN
RUBY LIBRARIES + NETWORK
TYPES OF CACHING
SKIPPING TO…
LOCALLY FETCHED
None
None
None
WAIT…FIXED FOREVER FOR FIXED FOR A PERIOD
None
NO CODE CONNECTION IS FAST CODE
Connection Takes Time
COPE WITH USE CASES
RUBY X THREE
BENCHMARKING
TOOLS FOR PARTIAL CODE https://github.com/evanphx/benchmark-ips https://github.com/jondot/benchmark-ipsa
WHY NOT NATIVE • Only few iterations runs with Benchmark.bm
or Benchmark.bmbm • Display time factors instead and need to guess a random iteration counts
None
None
None
TEST YOUR THEORY
TEST YOUR THEORY Constantized One Time Calculation
TEST YOUR THEORY
TEST YOUR THEORY
SEQUEL GEM https://github.com/jeremyevans/sequel
EVERYONE CAN CONTRIBUTE
FLAME GRAPHS FROM API
TOOLS?
RACK MINI PROFILER
AN ISSUE?
None
None
HTML
None
None
None
None
None
None
VERIFY!
None
LOAD TEST!
BEWARE! • APIs might have different result in different params
body • Test with the most common set from online metrics or your own tracking
調效能就跟洗浴缸⼀一樣,拔掉 那個塞⼦子,⽔水很快就流光了了
HAPPY HACKING
QA