Daniela Matos de Carvalho
Software Engineer @Dashlane, mother, photographer amateur, former @requirelx organiser, prev @YLDio, @zpx_interactive
Daniela Matos de Carvalho
NodeConf Barcelona 2017
sericaia
sericaia
Different access
(https://www.webworldwide.io/ for details)
Different access
Different bandwidth
Different latency
(image source: High Performance Browser Networking - Ilya Gregorik)
keep-alive connections
(image source: High Performance Browser Networking - Ilya Gregorik)
head-of-line blocking
multiple TCP connections
{sh1, sh2, sh3, sh4, sh5, sh6}.yld.io
myscript.js
anotherscript.js
stylesheet.css
bundle.js
.default {
background-image: url('image.png');
background-repeat: no-repeat;
width: 40px;
height: 60px;
background-position: 0 0;
}
(again!)
published in 2015
based on SPDY
extends HTTP 1.x
(image source: High Performance Browser Networking - Ilya Gregorik)
new Binary framing layer
(image source: High Performance Browser Networking - Ilya Gregorik)
1. Stream prioritization
2. Server push
3. Header compression
4. Flow control
1. Stream prioritization
1
12
1
4
1. Stream prioritization
1
12
1
4
dependencies and weights
index.html
styles.css
script-one.js
script-two.js
2. Server push
(image source: High Performance Browser Networking - Ilya Gregorik)
2. Server push
(image source: High Performance Browser Networking - Ilya Gregorik)
PUSH_PROMISE
RST_STREAM
...
3. Header
Compression
(HPACK)
(image source: High Performance Browser Networking - Ilya Gregorik)
4. Flow Control
SETTINGS
WINDOW_UPDATE
DATA
https://github.com/http2/http2-spec/wiki/Implementations
https://github.com/http2/http2-spec/wiki/Implementations
(Dev Tools > Network tab)
(Dev Tools > Network tab)
Text
TLS handshake!
GET https://http2.golang.org/gophertiles?latency=200
https://http2.golang.org/gophertiles?latency=200
DATA frame with the contents (image)
const spdy = require('spdy'),
fs = require('fs');
const options = {
cert: fs.readFileSync('keys/server.crt'),
ca: fs.readFileSync('keys/server.csr'),
key: fs.readFileSync('keys/server.key')
};
const server = spdy.createServer(options, (request, response) => {
response.writeHead(200, {
'content-type': 'text/html'
});
response.end(request.isSpdy ? 'SPDY is on :)' : 'SPDY is off :(');
});
const styles = fs.readFileSync('assets/style.css');
// ...
// index route handler
response.push('/style.css', {
response: {
'Content-Type': 'text/css'
}
}, function(err, stream){
if (err) {
return;
}
stream.end(styles);
});
// ...
Several implementations
- nodejs/http2 is also getting famous
(source: https://w3techs.com/technologies/details/ce-http2/all/all)
12.7% of the trafic is served using HTTP/2
(https://www.chromium.org/quic)
(https://ipfs.io/)
check out our blog.yld.io !
https://blog.yld.io/2017/01/10/http-2-a-look-into-the-future-of-the-web
https://blog.yld.io/2017/02/08/alternatives-to-http
https://blog.yld.io/2017/03/01/optimize-with-http-2-server-push-and-service-workers
Daniela Matos de Carvalho
NodeConf Barcelona 2017
sericaia
By Daniela Matos de Carvalho
Software Engineer @Dashlane, mother, photographer amateur, former @requirelx organiser, prev @YLDio, @zpx_interactive