| 1 |
[[performance]] |
| 2 |
== Performance |
| 3 |
|
| 4 |
This chapter describes the performance characteristics |
| 5 |
of Cowboy and offers suggestions to get the most |
| 6 |
performance out of your application. |
| 7 |
|
| 8 |
=== One process per connection |
| 9 |
|
| 10 |
The first version of Cowboy featured a single process |
| 11 |
per connection, whereas the current version of Cowboy |
| 12 |
features one process per connection plus one process |
| 13 |
per request. This has a negative impact on performance, |
| 14 |
but is necessary in order to provide a common interface |
| 15 |
for both HTTP/1.1 and HTTP/2 (as well as future HTTP |
| 16 |
versions). |
| 17 |
|
| 18 |
It is still possible to use a single process per |
| 19 |
connection, and avoid the creation of additional |
| 20 |
processes for each request, by implementing a |
| 21 |
stream handler to process the requests. This can |
| 22 |
be done for all requests, or just for a single |
| 23 |
endpoint depending on the application's needs. |
| 24 |
|
| 25 |
Stream handlers provide an asynchronous interface |
| 26 |
and must not block, so the implementation will |
| 27 |
be very different from normal Cowboy handlers, |
| 28 |
but the performance gains are important enough |
| 29 |
to justify it in some cases. |