Web Performance Part 2 "Network tips"

24
Web Performance Network Tips Mykyta Semenistyi & Andrew Kovalenko

description

The presentation is devoted to network and tips of improving Web Performance. Further presentations will dwell on more practical aspects of web applications performance improvement. All 4 presentations will help you reduce latency, enrich optimization of javascript code, discover tricky parts when working with API browser, see best practices of networking and learn lots of other important and interesting things. Enjoy! =)

Transcript of Web Performance Part 2 "Network tips"

Page 1: Web Performance Part 2  "Network tips"

Web PerformanceNetwork Tips

Mykyta Semenistyi & Andrew Kovalenko

Page 2: Web Performance Part 2  "Network tips"

Table of contents

1. CDN

2. Domain Sharding

3. Cache

4. Data Formats

5. Browser Enhancements (prefetch, preload, navigation timing)

6. XHR

7. WebSockets

8. WebRTC

Page 3: Web Performance Part 2  "Network tips"

Latency

Ilya Grigorik: High Performance Browser Networking

Page 4: Web Performance Part 2  "Network tips"

CDNContent Delivery Network

http://www.wpbeginner.com/beginners-guide/why-you-need-a-cdn-for-your-wordpress-blog-infographic/?display=wide

Page 5: Web Performance Part 2  "Network tips"

CDNadvantages

1. Minimal latency

2. Crash resistance

3. Headers reduced

4. Caching for public CDNs

Page 6: Web Performance Part 2  "Network tips"

CDNjsDelivr

● lots of libraries

● open-source, you may send pull-request

● can combine requests

● serves js and css

● wide network

Page 7: Web Performance Part 2  "Network tips"

Domain Shardingmotivation

https://developers.google.com/speed/articles/web-metrics

Page 8: Web Performance Part 2  "Network tips"

Domain Shardingmotivation

<div class="row"><div id="image-1" class="image"><img src="images/1.jpg"></div><div id="image-2" class="image"><img src="images/2.jpg"></div><div id="image-3" class="image"><img src="images/3.jpg"></div>

</div><div class="row">

<div id="image-4" class="image"><img src="images/4.jpg"></div><div id="image-5" class="image"><img src="images/5.jpg"></div><div id="image-6" class="image"><img src="images/6.jpg"></div>

</div>

} 2-6 conqequent requests per

domain

<div class="row"><div id="image-7" class="image"><img src="cdn.com/images/7.jpg"></div><div id="image-8" class="image"><img rsc="cdn.com/images/8.jpg"></div><div id="image-9" class="image"><img src="cdn.com/images/9.jpg"></div>

</div>

Page 9: Web Performance Part 2  "Network tips"

Domain Shardingsummary

● Use only 2 domains

● IP could be the same and only CNAME should be changed

● Measure everything by yourself: don’t forget about DNS resolve and TCP slow-start

● Sharding may not be quite good for mobile

Page 10: Web Performance Part 2  "Network tips"

Cacheheaders

cache-control expires etag (entity-tag)

pragma vary

private, max-age=0, no-cache

Thu, 01 Dec 1983 20:00:00 GMT

User-Agent

http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/

no-cache

"123456789"W/"123456789"

Page 11: Web Performance Part 2  "Network tips"

Data Formats

xml json custom format<page>

<title>Title</title><id>1529</id><revision><id>4382</id><timestamp>2006-09-18T22:11:53</timestamp>

</page>

{"title": "Title","id": 1529,"revision": 4382,"timestamp":

"2006-09-18T22:11:53Z"}

Title::1529::4382::2006-09-18T22:11:53Z

Page 12: Web Performance Part 2  "Network tips"

New in Browsers

DNS preresolve TCP preconnect

<link rel="dns-prefetch" href="//host_name_to_prefetch.com">

Ilya Grigorik http://www.igvita.com/posa/high-performance-networking-in-google-chrome/#predictor

Page 13: Web Performance Part 2  "Network tips"

New in Browsers

prerefetch

Ilya Grigorik http://www.igvita.com/posa/high-performance-networking-in-google-chrome/#predictor

<link rel="subresource" href="/myapp.js"> <link rel="prefetch" href="/big.jpeg">

prerender<link rel="prerender" href="http://site.org/index.html">

Page 14: Web Performance Part 2  "Network tips"

Navigation Timing

performance.timing

Page 15: Web Performance Part 2  "Network tips"

Resource Loading Strategies

Lazy-loading➔ scripts

➔ images

➔ etc.

Pre-loading

Page 16: Web Performance Part 2  "Network tips"

XHR streaming

var myRequest = new XMLHttpRequest();

myRequest.onreadystatechange = function(){//myRequest.readyState

}

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest

Page 17: Web Performance Part 2  "Network tips"

Oboe.js

Page 18: Web Performance Part 2  "Network tips"

WebRTC Excitement

➔ Audio➔ Video➔ Real-time communication➔ Peer-to-peer➔ Custom data transfer➔ Google, Mozilla и Opera

Page 19: Web Performance Part 2  "Network tips"

WebRTC

MediaStream RTCPeerConnection RTCDataChannel

acquisition of audio and video streams

communication of audio and video data

communication of arbitrary application

data

Page 20: Web Performance Part 2  "Network tips"

WebRTC audio and video engines

Ilya Grigorik: High Performance Browser Networking

Page 21: Web Performance Part 2  "Network tips"

WebRTC protocol stack

Ilya Grigorik: High Performance Browser Networking

Page 22: Web Performance Part 2  "Network tips"

RTCPeerConnection API

Page 23: Web Performance Part 2  "Network tips"

WebRTC browser support scorecard

http://iswebrtcreadyyet.com/

Page 24: Web Performance Part 2  "Network tips"

WebRTC 4 Allwebrtc4all is a WebRTC extension for Safari, Firefox, Opera and IE9+

Windows XP, Vista, 7 and 8 OS X UnixSafari Yes coming soon coming soon

Firefox Yes coming soon coming soon

IE Yes coming soon coming soon

Opera Yes coming soon coming soon