Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
jetty-client
netty-client
okhttp-client
server
README.md
pom.xml

README.md

multiplexing-examples

This project contains some examples of HTTP/2 multiplexing, i.e. HTTP/2's ability to handle multiple requests within one TCP connection independent of each other, so a blocked or stalled request or response does not prevent progress on other streams.

A blog post on the examples can be found on http://unrestful.io.

What does it do?

The server takes GET requests and answers them after 6 seconds delay. Each client sends three GET requests over a single connection. With HTTP/1 this would imply that the last response is received after 3*6=18 seconds. As the clients use HTTP/2, all requests are processed in parallel, so all three responses are received after 6 seconds.

The demo is implemented three times using three different HTTP/2 client libraries:

Prerequisites

Java 8

How to Run

git clone https://github.com/fstab/http2-examples.git
cd http2-examples/multiplexing-examples
mvn package

In order to run the examples, you need Jetty's ALPN boot JAR. Make sure to download the corresponding file or else it will not work.

Start the server:

java -Xbootclasspath/p:<path-to-alpn-boot-VERSION.jar> -jar server/target/server.jar

Run one of the clients:

java -Xbootclasspath/p:<path-to-alpn-boot-VERSION.jar> -jar jetty-client/target/jetty-client.jar
java -Xbootclasspath/p:<path-to-alpn-boot-VERSION.jar> -jar netty-client/target/netty-client.jar
java -Xbootclasspath/p:<path-to-alpn-boot-VERSION.jar> -jar okhttp-client/target/okhttp-client.jar