Yan (Peter) Li / Sep 2015
https://github.microstrategy.com/pages/yali/web-performance-and-future
View online
http://10.197.38.188/velocity/pdf
Download PDF
|
Hope it helps!
Frontend | + | Backend |
Year | Requests | Avg. Transfer Size | Growth |
---|---|---|---|
12/17/2010 | 82 | 655 KB | N/A |
12/15/2011 | 90 | 810 KB | 24% |
12/15/2012 | 99 | 1163 KB | 44% |
12/15/2013 | 112 | 1607 KB | 38% |
12/15/2014 | 117 | 1834 KB | 14% |
08/15/2015 | 128 | 2008 KB | 9% |
Site | Requests | Size | Time |
---|---|---|---|
www.163.com | 434 | 3.6 MB | 1.7 min |
www.taobao.com | 116 | 1.3 MB | 40.35 s |
www.jd.com | 79 | 1.6 MB | 1.2 min |
www.microsoft.com | 76 | 2.2 MB | 16.79 s |
www.microstrategy.com | 81 | 1.1 MB | 37.29 s |
Desktop | Mobile | |||
---|---|---|---|---|
Data rate | Latency | G | Data rate | Latency |
10 Mbps 100 Mbps 1 Gbps |
65-145 ms | 2G | 100-400 Kbps | 300-1000 ms |
3G | 0.5-1 Mbps | 100-500 ms | ||
4G | 1-50 Mbps | <100 ms |
http://www.webperformancetoday.com/2012/04/02/mobile-versus-desktop-latency/
http://chimera.labs.oreilly.com/books/1230000000545/ch07.html#_brief_history_of_the_g_8217_s
What rules/best practices do you know?
redirections | DNS | TCP | request response |
rendering |
minimize redirection |
reduce lookups |
image spriting minify |
caching domain sharding |
css on top js at bottom |
Similar graph: http://www.w3.org/TR/navigation-timing/#processing-model
redirections | DNS | TCP | request response |
rendering |
minimize redirection |
<meta http-equiv="refresh" content="5; url=http://example.com/">
window.location.reload(true); // document.location?
window.location.replace("http://www.z.cn");
window.location.assign("http://www.z.cn");
window.location.href = "http://www.z.cn";
window.location = "http://www.z.cn";
window.history.forward();
window.history.back();
window.history.go(-1);
redirections | DNS | TCP | request response |
rendering |
reduce lookups |
chrome://histograms/DNS.ResolveSuccess
<link rel="dns-prefetch" href="www.microstrategy.com">
Hint browser to pre-resolve these names
Supported: Chrome, Firefox, Safari, IE9+
redirections | DNS | TCP | request response |
rendering |
image spriting minify |
Host A | -----SYN-----> | Host B |
<---SYN ACK--- | ||
-----ACK-----> |
Tuning initcwnd for optimum performance
Linux TCP/IP tuning for scalability (tcp_slow_start_after_idle)
redirections | DNS | TCP | request response |
rendering |
caching domain sharding |
Caching Tutorial by Mark Nottingham
Check your pages with REDbot
Browser | 2(1999) simultaneous connections 6-8(2010) simultaneous connections | Domain |
http://www.mobify.com/blog/domain-sharding-bad-news-mobile-performance/
<link rel="prefetch" href="next-page.css">
<link rel="subresource" href="critical.js">
redirections | DNS | TCP | request response |
rendering |
css on top js at bottom |
http://www.smashingmagazine.com/2015/08/understanding-critical-css/
Alva Cheung
“Load non-critical features asynchronously”
<link rel="prerender" href="http://www.microstrategy.com">
Initiate background pre-render of entire page
Supported: Chrome, Firefox
Why care?
Static Web Pages | Interactive |
---|---|
|
|
Speed up runtime method binding by remembering the results of a previous method lookup directly at the call site
function addTwoThings(thing1, thing2) {
return thing1 + thing2;
}
addTwoThings(1, 2);
addTwoThings(100, 200); /* fast */
addTwoThings('a', 'b'); /* slow */
function Dog(name) {
this.name = name;
}
var dog1 = new Dog('Jim'); /* hidden class C1 */
var dog2 = new Dog('Bin'); /* hidden class C2 */
dog2.gender = 'male';
onresize, onscroll...etc
var $div = $('#content')
var elements = ['a', 'b', 'c', 'd'];
for(var i=0,l=elements.length; i<l; i++) {
$div.append(elements[i]);
}
var $div = $('#content')
var elements = ['a', 'b', 'c', 'd'];
for(var i=0,l=elements.length; i<l; i++) {
// one line of evilness
var a = $(window).scrollTop;
$div.append(elements[i]);
}
.class ul li a { color: blue; }
border-radius; box-shadow; transform,filter; :nth-child; position:fixed;
*; [disabled]; [type="text"]
Request | Response | |
---|---|---|
HTTP/2 Client | HTTP/1.1 Server | HTTP/2 Server |
|
|
|
HTTP + SSL/TLS = HTTPS
Equally Important!
“TLS has exactly one performance problem: it is not used widely enough.
Everything else can be optimized.”
Dive deeper: YouTube - Is TLS Fast Yet?
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
Strict-Transport-Security: max-age=10886400; includeSubDomains
Browser remembers (for specified max-age period) that it should automatically request HTTPS resources for this site and its subdomains.
HSTS eliminates HTTP --> HTTPS redirects.
Web Development Reading List: https://wdrl.info/
WeChat ID: peterleepersonal