Cables: A multiplexed HTTP/2 Elixir Client

Announcing Cables, a fast async HTTP/2 client.


With Phoenix and Plug supporting HTTP/2, Elixir needs a client to take advantage of one of the major features of HTTP/2: multiplexing with streams.

Cables is a client to work with HTTP/2 streams. One connection can support multiple requests simultaneously. It defines a behavior to build your own async consumers, or you can use the generic REST methods (get, put, etc)

You can see how to implement a handler here: https://github.com/hansonkd/cables/blob/master/lib/cables/response.ex

It is based on the HTTP/2 library, Gun, which provides persistent HTTP/2 connections. Cables will try to reuse existing connections as much as possible and can spin up new connections as the load grows and cleans them up when they aren’t needed.

To get an idea of the optimal number of streams per connection, take a look at the benchmark repo which performs some naive benchmarks with different configurations:

Its still in its experimental phase, so there may be some bumps. Hopefully, it is enough to start building HTTP/2 apps with!

9 Likes

Interesting project! How is development going?

1 Like