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
The short but happy lives of TCP and HTTP requests
Search
Starr Horne
September 19, 2014
Programming
4
380
The short but happy lives of TCP and HTTP requests
A talk about network optimization given at the 2014 Golden Gate Ruby Conference.
Starr Horne
September 19, 2014
Tweet
Share
More Decks by Starr Horne
See All by Starr Horne
Ditching the Single Page Application - Madison+Ruby 2015
snhorne
0
240
Ditching the Single Page Application (RubyNation 2015)
snhorne
1
230
SVG Charts and Graphs With Ruby
snhorne
0
130
SVG Charts and Graphs With Ruby
snhorne
0
340
Machine Learning Techniques You Can Use Today
snhorne
4
190
Biggish Data with Rails and Postgresql
snhorne
3
880
Other Decks in Programming
See All in Programming
TYPO3 v13 – The road to LTS: What's new and new APIs
luisasofie_xoxo
0
180
見た目から始める生産性向上
ikumatadokoro
4
210
今、知っておきたい! 生成AIエージェントの世界
elith
3
340
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
1.2k
HUIT新歓2024「競技プログラミング、やってみませんか?」
slephy2784
1
250
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
500
Zero Waste, Radical Magic, and Italian Graft – Quarkus Efficiency Secrets
hollycummins
0
220
Tailwind CSSを本気でカスタマイズする方法
fsubal
9
3.3k
本格ローグライク制作にEbitengineを選んでみた
nagainaganawa
0
290
PHPの次期バージョンはこの時期どうなっているのか - Internalsの開発体制について - PHPカンファレンス小田原
youkidearitai
PRO
1
180
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
150
StreamlitとTerraformでデータカタログを作った話
gussan0223
0
310
Featured
See All Featured
Producing Creativity
orderedlist
PRO
336
39k
Building Applications with DynamoDB
mza
88
5.6k
Happy Clients
brianwarren
91
6.4k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
104
6.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
220
21k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.3k
Pencils Down: Stop Designing & Start Developing
hursman
117
11k
Product Roadmaps are Hard
iamctodd
43
9.7k
Robots, Beer and Maslow
schacon
PRO
155
7.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
No one is an island. Learnings from fostering a developers community.
thoeni
14
2.1k
GitHub's CSS Performance
jonrohan
1023
450k
Transcript
@StarrHorne Hi everybody!! ! I’ll be tweeting this ! slide
deck later at ! @StarrHorne ! ! That’s me!! ! ! ps. Use Honeybadger to monitor your Rails apps for exceptions. (Now my trip is tax deductible!)
@StarrHorne
@StarrHorne
@StarrHorne Short but happy
@StarrHorne Short but happy The lives of HTTP requests
@StarrHorne
@StarrHorne
@StarrHorne
@StarrHorne
@StarrHorne
@StarrHorne
@StarrHorne
@StarrHorne Welcome to the internet I’ll be your guide
@StarrHorne OSI Model
@StarrHorne
@StarrHorne
@StarrHorne
@StarrHorne
@StarrHorne Wires
@StarrHorne Latency ! ! ! Time spent “in the wire”
! ps. it ain’t bandwidth
@StarrHorne Latency ! ! ! Time spent “in the wire”
! ps. it ain’t bandwidth
@StarrHorne Minimum latency (determined by speed of light) http://trollphysics.tumblr.com
@StarrHorne Minimum latency (determined by speed of light) http://trollphysics.tumblr.com
@StarrHorne 299,792,458 m/s (Speed of light in a vacuum) http://trollphysics.tumblr.com
@StarrHorne Don’t call it SOL in a vacuum (That’s something
else) http://trollphysics.tumblr.com
@StarrHorne
@StarrHorne ! 5,578,593(m) ÷ 299,792,458 (m/s) = 0.0186 (s) !
0.0186 * 1000 (ms/s) = 18.6ms ! 18.6 * 2 = 37.2 ms round trip NYC <=> LON Latency (minimum theoretical)
@StarrHorne
@StarrHorne Latency kills UX 100 ms Doesn’t seem instantaneous 250
ms Feels sluggish 500 ms I start to get distracted 1000 ms I’m cussing at the computer
@StarrHorne Easy Move servers closer to users.
@StarrHorne Harder Eliminate Round Trips
@StarrHorne The Data Link
@StarrHorne Bandwidth It must be important. Just look at that
dude’s face!
@StarrHorne Except when it’s not Source: High Performance Browser Networking
( http://bit.ly/high-performance-browser-networking )
@StarrHorne
@StarrHorne The “lots of small files” problem Slower Faster
@StarrHorne Blame the protocols IP Routes packets between computers No
guarantees of delivery. TCP A simulation of a stable network running on top of IP. HTTP Sends one file at a time over TCP connections.
@StarrHorne ! NEW TCP CONNECTIONS ARE EXPENSIVE
@StarrHorne Opening a connection Hey, we should talk Sure, about
what? Awesome. Send me that funny cat pic
@StarrHorne New connection overhead (1 round trip. 20-100ms depending)
@StarrHorne ! YOU’RE NOT GETTING OFF THAT EASY
@StarrHorne CONGESTION CONTROL
@StarrHorne Slow Start
@StarrHorne Let’s see… Thats 10 round trips at (we’ll assume)
40ms latency. Holy crap that’s 400ms!!!
@StarrHorne ! NEW TCP CONNECTIONS ARE EXPENSIVE
@StarrHorne Keep-Alive Browser opens one TCP connection uses it for
multiple HTTP requests. ! ! ! ! ! ! ! …actually, you get 6 connections per domain.
@StarrHorne Your server controls keepalive ! ! Apache: http://bit.ly/apache-ka !
Nginx: http://bit.ly/nginx-ka !
@StarrHorne “Slow start after idle” kills keepalive ! $> sysctl
net.ipv4.tcp_slow_start_after_idle ! $> sysctl -w net.ipv4.tcp_slow_start_after_idle=0
@StarrHorne TCP Tuning Make sure you’re running a recent linux
kernel If you insist: http://bit.ly/tcp-tuning
@StarrHorne HTTP, WTF!?
@StarrHorne >telnet cern.ch 80 GET /cat.txt HTTP/1.0 host: www.esqsoft.globalservers.com
@StarrHorne >telnet cern.ch 80 GET /cat.txt HTTP/1.0 host: www.esqsoft.globalservers.com
@StarrHorne
@StarrHorne
@StarrHorne
@StarrHorne 112 (Requests per webpage on average)
@StarrHorne Browser Caching (Response headers) Last-Modified Tell the browser when
this file was last modified. ETag Supplies an ETag the browser can use to check freshness. Expires Tells the browser to keep the page until a certain date http://bit.ly/http-caching
@StarrHorne 112 (Requests per webpage on average)
@StarrHorne Concatenate JS & CSS (Hello asset pipeline)
@StarrHorne
@StarrHorne
Down to 30 requests (But I feel dirty for some
reason) @StarrHorne
@StarrHorne
@StarrHorne Could we do them CONCURRENTLY? ! ! ! !
! You DO get 6 connections per domain. And you DO know how to make domains.
@StarrHorne farm4.staticflickr.com farm8.staticflickr.com farm8.staticflickr.com farm4.staticflickr.com farm6.staticflickr.com farm3.staticflickr.com http://bit.ly/p-speed
@StarrHorne I guess you could call it an ugly hack
@StarrHorne www.honeybadger.io d3aei7d2k8qp8j.cloudfront.net cdnjs.cloudflare.com d3dy5gmtp8yhk7.cloudfront.net cdnjs.cloudflare.com But we do it
anyway (As a side-effect of using CDNs)
@StarrHorne Move requests out of band (Supported by newer browsers)
! <script async="async" src="/my.js"></script> ! <link rel="prefetch" href=“/big.jpeg"> ! <link rel="prerender" href=“/next.html”> ! <link rel="dns-prefetch" href="//blah.com">
@StarrHorne Summary ! Move your servers closer to your users
(CDNs) ! Make sure keep-alive works ! Keep cookie size small ! Serve fewer files by whatever means necessary ! Shard files across domains if you must !
@StarrHorne The cavalry is on the way!
@StarrHorne SPDY ! Much better at the “lots of small
files” thing ! Supported by many (but not all) clients ! You still need CDNs for geography ! Requires SSL
@StarrHorne HTTP 2.0 ! Coming soon. ! Also focused on
the “lots of small files” problem ! But HTTP 1.4 ain’t going anywhere soon.
@StarrHorne Buy this book ! You can also read it
online for free - legally! ! http://bit.ly/high-performance-browser-networking
@StarrHorne I’ll be tweeting this slide deck later at @StarrHorne