HTTP libraries in Ruby

What do we have?

Ruby’s built-in library: Net/HTTP and gems that powers Net/HTTP:

3rd-party libraries:

Based on Net/HTTP

REST Client, httparty, and Nestful.

Based on libcurl

curb, EM-HTTP-Request, Patron, and Typhoeus.

Pure Ruby

EM-Synchrony, excon, Faraday, httpclient, HTTPX, and net-http2.

Pure Ruby + http_parser.rb


Socks 5


There are probably many more I did not know about, what should we choose?

What people are using?

...Don’t worry, it’s very easy to evaluate.

What should I evaluate a HTTP library?

  • Easy to use API

  • Fast (Keep-Alive, HTTP/2 Connection Coalescing)

  • Low memory usage

  • Network usage ((de)compression of request/response)

    So you send smaller request / receive small response = Less network usages.

  • Concurrent support by protocol (HTTP pipeline, HTTP/2 multiplex)

  • Less Dependencies
    Less dependencies to keep up; Less memory; If you’re building a client of a service, you probably want to have no dependency in order to have as many users as possible.

  • Possible to fit all scenarios you need
    We want one gem to rule them all.

Let’s rule out gems that do not comes with what we want:

httparty does not have Keep-Alice support (you need persistent_httparty to keep the party alive). REST Client uses too much memory and currently the slowest. EM-* also requires multiple gems. Net/HTTP’s API is not very easy to use.

Now we still have many libraries to choose from. How about we consider some of HTTP/2 features? Now we left with only HTTPX...


  • HTTP/2 & concurrent requests

    The concurrency are done via HTTP protocol’s features: HTTP/2 multiplex & HTTP Pipeline support without you do any work, same API. It is based on a plugin-in system, you only use what you need, lightweight.

  • The documentation is simple

  • All HTTP features are well tested by httpbin.

  • ALPN support to reduce latency (if you use HTTPS resolver for DNS)

  • Alt-Svc support that directs you to the right/closest server

Getting Started with HTTPX

See HTTPX wiki.