Cowboy
By the Erlang/OTP community
1, HTTP/2, and the WebSocket protocol upgrade handshake. It serves as the default underlying web server for the Phoenix framework and a wide range of other Erlang and Elixir web applications and services running in production.
Definition
Cowboy is a small, fast HTTP server for Erlang and the wider BEAM ecosystem, designed to be lightweight, standards-compliant, and to closely follow HTTP specifications including HTTP/1.1, HTTP/2, and the WebSocket protocol upgrade handshake. It serves as the default underlying web server for the Phoenix framework and a wide range of other Erlang and Elixir web applications and services running in production.
Overview
Cowboy was developed to provide Erlang applications with an HTTP server that was small, correct with respect to the relevant HTTP specifications, and able to take full advantage of the BEAM virtual machine's lightweight-process concurrency model, at a time when other options in the Erlang ecosystem were either less standards-compliant or not built with the same performance goals. Its design philosophy favors simplicity and a small codebase over an extensive plugin architecture, delegating more application-level concerns to layers built on top of it. Mechanically, Cowboy accepts incoming TCP connections and spawns a lightweight BEAM process per connection, and typically a process per request as well, relying on the BEAM scheduler to handle large numbers of concurrent connections efficiently without the server itself needing custom thread-pool or event-loop management. It implements HTTP/1.1 parsing, HTTP/2 multiplexing, and the WebSocket upgrade handshake and framing directly, exposing handler behaviors that application code implements to process requests, stream responses, or manage a WebSocket connection's lifecycle. Among Erlang and Elixir HTTP servers, Cowboy has effectively become the standard choice, having displaced earlier options like Erlang's built-in inets httpd and Mochiweb for most new projects due to its stronger standards compliance and ongoing maintenance. It is comparable in role to servers like Node.js's underlying HTTP implementation or Netty in the JVM world, providing the low-level connection and protocol handling that higher-level frameworks build routing, middleware, and templating on top of. In practice, Cowboy is used directly by developers building lightweight Erlang web services who want HTTP handling without a full framework, and indirectly by the large number of Phoenix applications that rely on it as their default HTTP server underneath Phoenix's routing, controllers, and LiveView WebSocket handling. It is also used as the transport layer for Erlang and Elixir libraries that expose WebSocket-based APIs. Cowboy's main trade-off is that, by design, it stays low-level: it does not provide routing conventions, templating, or the higher-level application structure that a framework like Phoenix supplies, so teams building anything beyond a very small service typically use it through a framework rather than directly. Its scope is intentionally narrow, which is a strength for composability but means it is rarely the whole answer to building a web application on its own. Cowboy is developed and maintained alongside a small family of related Erlang libraries, including Ranch for TCP connection acceptance and Cowlib for HTTP protocol parsing utilities, which together form the lower layers of the stack that Phoenix and other frameworks build upon.
Key Features
- Implements HTTP/1.1, HTTP/2, and WebSocket protocols directly in Erlang
- Spawns a lightweight BEAM process per connection and typically per request
- Relies on the BEAM scheduler for efficient handling of concurrent connections
- Serves as the default underlying HTTP server for the Phoenix framework
- Exposes handler behaviors for processing requests and streaming responses
- Prioritizes a small, standards-compliant codebase over a plugin-heavy architecture
- Provides the transport layer for WebSocket-based Erlang and Elixir libraries