better performances with http/2 and eclipse vert · better performances with http/2 and eclipse...

46
Beer performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Soſtware Engineer, Red Hat

Upload: others

Post on 30-May-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Better performances with HTTP/2and Eclipse Vert.xThomas Segismont, Senior Software Engineer, Red Hat

Page 2: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Agenda

• Improving web performance with HTTP/2

• Scalable service architectures with HTTP/2

Page 3: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Who am I?

• tsegismont @ GitHub / Twitter / Gmail / Freenode

• Vert.x core team since August 2016

• At Red Hat since November 2012 (RHQ and Hawkular)

Page 4: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

IMPROVING WEB PERFORMANCE WITH

HTTP/2

Page 5: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving
Page 6: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving
Page 7: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Latency matters more!

100015502100265032003750

10001750250032504000

Page 8: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

HTTP/1 Optimization techniques

• Persistent connections

• Multiple connections

• Domain sharding

• CDN

• Browser caching

• Compression / minification

• Concatenation

Page 9: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Still a bottleneck!

GET

OK

GET

OK

Page 10: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

HTTP/2

• A better TCP transport for actual HTTP request and responses

• Same HTTP semantics

• RFC7540 : Hypertext Protocol version 2

• RFC7541 : Header Compression for HTTP/2

Page 11: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

HTTP/2

• H2– TLS/SSL

– Mandatory for browsers

– ALPN extension to negotiate HTTP/1 or HTTP/2

• H2C– Clear text

– Via HTTP/1 upgrade or directly

Page 12: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Framed protocol

• Defines a set of frames encoded in binary on a single connection

– Settings

– Headers

– Data

– Flow control

– Push, Priority, Ping

– Reset

Page 13: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Settings frames

• First frame exchanged by client and server– Max concurrency

– Max frame size

– … etc

Page 14: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

GET /index.html HTTP/1.1\r\nHost: www.free.fr\r\nUser-Agent: Mozilla/5.0\r\nAccept-Encoding: text/html\r\nAccept-Language: en-US\r\n\r\n

000035012500000003000000000f824488355217caf3a69a3f874189f1e3c2f2d852af2d9f7a88d07f66a281b0dae05087497ca589d34d1f51842d4b70dd

Request headers

2x smaller

length type flags stream_id

Page 15: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Subsequent request headers

4x smaller

GET /products.html HTTP/1.1\r\nHost: www.free.fr\r\nUser-Agent: Mozilla/5.0\r\nAccept-Encoding: text/html\r\nAccept-Language: en-US\r\n\r\n

000017012500000005000000000f82448aaec3c9691285e74d347f87c2c1c0bf

Page 16: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Response headers + data

HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nCache-Control: max-age=86400\r\nContent-Length: 37\r\n\r\n<html><body>Hello World</body></html>

00001f012400000003000000000f885f87497ca589d34d1f588aa47e561cc581e71a003f5c023337

0000250001000000033c68746d6c3e3c626f64793e48656c6c6f20576f726c643c2f626f64793e3c2f68746d6c3e

length type flags stream_id

Page 17: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

DEMO

Page 18: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

SCALABLE SERVICES WITH HTTP/2

Page 19: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Target architectures

serviceservice

serviceservice

gatewaygateway

backendbackend

serviceservicebackendbackend

Page 20: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Constraints

• 1ms ping

• 1G < bandwidth < 10G

• 1ms < service time < 200ms

• 200b < body size < 2kb

Page 21: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

HTTP/1.1 vs HTTP/2

serverserver

HTTP/1vs

HTTP/2

backendbackendclientclient20 msthinktime

Page 22: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

0 100 200 300 400 500 600 700 8000

200

400

600

800

HTTP/1 - 8 connections

planned (req / sec)

per

form

ed (

req/

sec)

Page 23: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

HTTP/1.1 Head Of Line Blocking

Client Server

} 20ms

Backend

GET

}

Page 24: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

0 100 200 300 400 500 600 700 800 900 1000 1100 12000

300

600

900

1200

HTTP/1 - 8 connectionsHTTP/2 - 1 connection / max_concurrent_streams 20

planned (req / sec)

perf

orm

ed (

req

/ sec

)

Page 25: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

HTTP/2.0 Multiplexing

Client Server

} 20ms

Backend

request

}}

Page 26: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Thread pool concurrency

Page 27: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

0 1000 2000 3000 4000 50000

1250

2500

3750

5000

HTTP/2 thread pool

planned (req / sec)

perf

orm

ed (

req

/ sec

)

Page 28: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Eclipse Vert.x is a toolkit for building reactive and polyglot

applications for the JVM

Page 29: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Vert.x

• Latest and greatest Vert.x 3.4.1– Scala and Kotlin support

– RxJava improvements

– MQTT server

– Kafka client

– gRPC support

– Web client

– Infinispan cluster manager

– … and much more!

Page 30: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Toolkit

• Embeddable

• Composable

• Modular

• Minimum dependencies

• Classloading / Injection free

Page 31: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Polyglot

Page 32: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Reactive

• Non blocking

• Event driven

• Distributed

• Rxified APIs

• Reactive-streams

Page 33: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

HTTP/2 with Vert.x

• Client / Server

• h2 / h2c

• HTTP Request / response API

• HTTP/2 specific features for extensions

Page 34: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

DEMO

Page 35: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Event Driven

• NIO selectors

• Disk operations

• Timers

• Messages

• Database

• … etc

Page 36: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Reactor pattern with Event Loop

Singlethread

Page 37: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Event loop benefits

• Easier to scale

• Mechanical sympathetic

• Simple concurrency model

Page 38: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Event loop concurrency

Page 39: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

0 1000 2000 3000 4000 50000

1250

2500

3750

5000

HTTP/2 thread pool HTTP/2 non blocking

planned (req / sec)

perf

orm

ed (

req

/ sec

)

Page 40: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Multi-reactor pattern

Page 41: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving
Page 42: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving
Page 43: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Conclusion

• Unleash concurrency with HTTP/2

• Keep the good old HTTP/1 semantics

• Non blocking is a key factor for high concurrency

• Vert.x is a great fit for HTTP/2– Reactive ecosystem

– Easy to scale

Page 44: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Thank you

Page 45: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

Links

• http://vertx.io

• https://github.com/vietj/http2-bench

• http://www.belshe.com/2010/05/24/more-bandwidth-doesnt-matter-much/

• https://www.infoq.com/presentations/latency-pitfalls

• https://hpbn.co

Page 46: Better performances with HTTP/2 and Eclipse Vert · Better performances with HTTP/2 and Eclipse Vert.x Thomas Segismont, Senior Software Engineer, Red Hat ... Agenda • Improving

www.modsummit.com

www.developersummit.com