0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00
Commit graph

190 commits

Author SHA1 Message Date
Loïc Hoguin
761c1f8dca
Relax Ranch version requirement for Hex
It is now specified as >= 1.8.0 and < 3.0.0 since Cowboy
supports both Ranch 1.8.x and 2.x.
2025-02-11 16:02:10 +01:00
Loïc Hoguin
d889291c4f
Don't run perf suites by default 2025-02-05 14:30:25 +01:00
Loïc Hoguin
086f60cca4
Avoid resetting Websocket idle_timeout timer too often
`perf` has shown that Cowboy spends a lot of time
cancelling and starting this timer. Instead of resetting
for every data received, we now only reset a field in the
state.

Before it was working like this:

- start idle timeout timer
- on trigger, close the connection
- on data, cancel and start again

Now it's working like this:

- start idle timeout timer for a tenth of its duration, with tick number = 0
- on trigger, if tick number != 10
  - start the timer again, again for a tenth of its duration
  - increment tick number
- on trigger, if tick number = 10
  - close the connection
- on data, set tick number to 0
2025-01-15 13:31:19 +01:00
Loïc Hoguin
643b335ba8
Add ws_perf_SUITE to measure Websocket performance
It benchmarks binary, ascii, mixed and japanese data
using Websocket and Websocket over HTTP/2.

HTTP/2 options get set to ensure that performance is
better than the default HTTP/2 options.

It switches to Gun and Ranch branches that include
fixes that are required for tests to complete successfully.
2025-01-15 13:28:57 +01:00
Loïc Hoguin
8cb9d242b0
Initial HTTP/3 implementation
This includes Websocket over HTTP/3.

Since quicer, which provides the QUIC implementation,
is a NIF, Cowboy cannot depend directly on it. In order
to enable QUIC and HTTP/3, users have to set the
COWBOY_QUICER environment variable:

  export COWBOY_QUICER=1

In order to run the test suites, the same must be done
for Gun:

  export GUN_QUICER=1

HTTP/3 support is currently not available on Windows
due to compilation issues of quicer which have yet to
be looked at or resolved.

HTTP/3 support is also unavailable on the upcoming
OTP-27 due to compilation errors in quicer dependencies.
Once resolved HTTP/3 should work on OTP-27.

Because of how QUIC currently works, it's possible
that streams that get reset after sending a response
do not receive that response. The test suite was
modified to accomodate for that. A future extension
to QUIC will allow us to gracefully reset streams.

This also updates Erlang.mk.
2024-03-26 15:53:48 +01:00
Loïc Hoguin
3ea8395eb8
Cowboy 2.12.0 2024-03-14 15:06:07 +01:00
Loïc Hoguin
cf71c742d6
Add max_fragmented_header_block_size HTTP/2 option 2024-03-14 12:56:33 +01:00
Loïc Hoguin
7d3aa6c9dd
Run make ct-examples at the end of normal CI 2024-01-26 12:34:37 +01:00
Loïc Hoguin
8f9051519e
Cowboy 2.11 2024-01-23 15:29:41 +01:00
Loïc Hoguin
cff9938a66
Show links in README in make prepare_tag 2024-01-17 12:55:52 +01:00
Loïc Hoguin
879a6b8bc5
Remove unneeded Makefile variables 2023-12-04 11:11:54 +01:00
Loïc Hoguin
521266326d
Don't dialyze the tests by default 2023-12-01 11:08:01 +01:00
Loïc Hoguin
d64ac25e92
Use GitHub actions for testing Cowboy
Now tested against OTP-24+.
Erlang.mk has been updated as well.
2023-12-01 10:00:33 +01:00
Loïc Hoguin
9e600f6c1d
Cowboy 2.10.0 2023-04-28 10:41:18 +02:00
Loïc Hoguin
326939c8a8
We are not using erl_make_certs anymore 2023-03-30 16:38:08 +02:00
Loïc Hoguin
4958af5745
Update Cowlib to 2.12.1 2023-03-29 15:20:48 +02:00
Loïc Hoguin
2a08250499
Add Hex metadata 2021-05-12 12:04:03 +02:00
Loïc Hoguin
04ca4c5d31
Cowboy 2.9.0 2021-05-12 10:24:40 +02:00
Loïc Hoguin
880c72ef99
Cowlib 2.11.0 and Ranch 1.8.0 2021-04-24 16:31:14 +02:00
Viktor Söderqvist
059d58d39f
Graceful shutdown
Note: This commit makes cowboy depend on cowlib master.

Graceful shutdown for HTTP/2:

1. A GOAWAY frame with the last stream id set to 2^31-1 is sent and a
   timer is started (goaway_initial_timeout, default 1000ms), to wait
   for any in-flight requests sent by the client, and the status is set
   to 'closing_initiated'. If the client responds with GOAWAY and closes
   the connection, we're done.
2. A second GOAWAY frame is sent with the actual last stream id and the
   status is set to 'closing'. If no streams exist, the connection
   terminates. Otherwise a second timer (goaway_complete_timeout,
   default 3000ms) is started, to wait for the streams to complete. New
   streams are not accepted when status is 'closing'.
3. If all streams haven't completed after the second timeout, the
   connection is forcefully terminated.

Graceful shutdown for HTTP/1.x:

1. If a request is currently being handled, it is waited for and the
   response is sent back to the client with the header "Connection:
   close". Then, the connection is closed.
2. If the current request handler is not finished within the time
   configured in transport option 'shutdown' (default 5000ms), the
   connection process is killed by its supervisor (ranch).

Implemented for HTTP/1.x and HTTP/2 in the following scenarios:

* When receiving exit signal 'shutdown' from the supervisor (e.g. when
  cowboy:stop_listener/3 is called).
* When a connection process is requested to terminate using
  sys:terminate/2,3.

LH: Edited tests a bit and added todos for useful tests to add.
2020-11-27 15:38:21 +01:00
Loïc Hoguin
8d5628c5f1
Cowboy 2.8.0 2020-05-21 19:02:12 +02:00
Loïc Hoguin
8471788826
Update Cowlib to 2.9.1
Fixes HPACK edge cases (error conditions).
2020-04-01 20:14:35 +02:00
Loïc Hoguin
6b3fa5bb76
Update Cowlib to 2.9.0 2020-03-30 15:02:31 +02:00
Loïc Hoguin
ab82d316b0
Cowboy itself doesn't use proper; Cowlib does 2020-03-29 13:20:57 +02:00
Loïc Hoguin
db0d6f8d25
Use active,N
This reduces the number of times we need to ask for more packets,
and as a result we get a fairly large boost in performance,
especially with HTTP/1.1.

Unfortunately this makes Cowboy require at least Erlang/OTP 21.3+
because the ssl application did not have active,N. For simplicity
the version required will be Erlang/OTP 22+.

In addition this change improves hibernate handling in
cowboy_websocket. Hibernate will now work for HTTP/2 transport
as well, and stray or unrelated messages will no longer cancel
hibernate (the process will handle the message and go back into
hibernation).

Thanks go to Stressgrid for benchmarking an early version of this
commit: https://stressgrid.com/blog/cowboy_performance_part_2/
2020-01-06 12:58:14 +01:00
Loïc Hoguin
3fb55f076f
Add a commented option in the Makefile 2019-12-31 11:12:04 +01:00
Loïc Hoguin
525eeeecc9
Cowboy 2.7.0 2019-10-10 16:15:51 +02:00
Loïc Hoguin
7bccad4d21
Only test on the latest release per OTP major version by default 2019-09-18 09:48:12 +02:00
Loïc Hoguin
702c7ff788
Use Gun master for tests
We no longer support OTP-19 so we don't need to stay on the
old Gun version anymore.
2019-09-06 12:30:25 +02:00
Loïc Hoguin
48f417ac8f
Fix and optimize sending of WINDOW_UPDATE frames
For long-running connections it was possible for the connection
window to become larger than allowed by the protocol because the
window increases claimed by stream handlers were never reclaimed
even if no data was consumed.

The new code applies heuristics to fix this and reduce the number
of WINDOW_UPDATE frames that are sent. It includes six new options
to control that behavior: margin, max and threshold for both the
connection and stream windows. The margin is some extra space
added on top of the requested read size. The max is the maximum
window size at any given time. The threshold is a minimum window
size that must be reached before we even consider sending more
WINDOW_UPDATE frames. We also avoid sending WINDOW_UPDATE frames
when there is already enough space in the window, or when the
read size is 0.

Cowlib is set to master until a new tag is done.
2019-09-05 14:07:38 +02:00
Loïc Hoguin
aedf6379cc
Update CI to only test on OTP-20+ 2019-08-29 16:59:03 +02:00
Loïc Hoguin
d846827b2a
Cowboy 2.6.3 2019-04-05 11:09:55 +02:00
Loïc Hoguin
39a0bf4bee
Add a prepare_tag target to help with releasing 2019-04-05 11:08:33 +02:00
Loïc Hoguin
d5489b4c73
Cowboy 2.6.2
Updates Cowlib to 2.7.2.
2019-04-04 11:23:50 +02:00
Loïc Hoguin
6f68d7d2d6
Use Gun 1.2.0 for tests to avoid OTP-19 issues
And temporarily depend on Cowlib master to confirm everything
works as intended.
2019-04-03 15:53:51 +02:00
Loïc Hoguin
867ca66fab
Cowlib 2.7.1 2019-04-01 15:04:33 +02:00
Loïc Hoguin
b9d329c026
Don't error out when h2spec can't be compiled 2019-03-10 11:21:51 +01:00
Loïc Hoguin
4918e271bd
Use Gun 1.3.0 instead of master for tests 2019-03-08 16:04:55 +01:00
Loïc Hoguin
e0254cdcb0
Cowboy 2.6.1 2018-11-28 12:15:17 +01:00
Loïc Hoguin
291d493c21
Update Ranch to 1.7.1 2018-11-28 12:11:08 +01:00
Loïc Hoguin
7b5da29019
Don't run long test suites by default
The examples test suite is only useful once in a while
in order to know whether examples were broken, for example
before issuing a release.

The new ws_autobahn test suite isolates the autobahn test
suite so that it can be ignored by default. It's only
useful to run it when working on the Websocket code or
before issuing a release.
2018-11-20 13:23:59 +01:00
Loïc Hoguin
417032a445
Prepare the Cowboy 2.6 release 2018-11-17 13:36:14 +01:00
Loïc Hoguin
1e2d59ed26
Ranch 1.7.0 2018-11-14 12:33:43 +01:00
Loïc Hoguin
a8335c63df
Always dialyze tests and fix some cowboy_req specs 2018-10-31 10:50:57 +01:00
Loïc Hoguin
122faedc25
Initial support for the PROXY protocol header
Depend on Ranch master for now since it isn't in any release yet.
2018-10-30 23:30:54 +01:00
Loïc Hoguin
e1d970b5eb
Switch cowboy_http2 to the new cow_http2_machine
The new module is a merge of the Cowboy and Gun HTTP/2
state machines. Using a common code will help future
developments rather than duplicating the work.

A notable change is in how streams are terminated
when the handler stops before the body is sent. The
cowboy_stream:terminate function is now called only
after the body has been sent fully (or the stream
is reset in-between), not when the stop command is
returned. This will most likely have an impact on
metrics but will be closer to reality.

I had to comment a broken test in rfc7231_SUITE that
was cheating, cheating is no longer possible.

This depends on Cowlib master for the time being. A
new Cowlib version will be released once both Cowboy
and Gun are ported to use cow_http2_machine and I'm
satisfied with it.
2018-10-26 10:23:28 +02:00
Loïc Hoguin
a428b10abf
Shorten a command in the Makefile 2018-10-02 09:36:07 +02:00
getong
4493afbba0
Update Ranch to 1.6.2 2018-09-23 14:24:37 +02:00
Loïc Hoguin
9901a3b568
Update Cowlib to 2.6.0 2018-09-21 15:12:58 +02:00
Loïc Hoguin
26bc4afad4
Prepare the 2.5.0 release 2018-09-12 15:00:48 +02:00