-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documentation on retry-mechanisms and gun choice
- Loading branch information
1 parent
f65f4d3
commit 561b84a
Showing
4 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Why :gun? | ||
|
||
Slipstream is built off of [`:gun`](https://hex.pm/packages/gun), | ||
an HTTP and websocket client from the wonderful | ||
[`@ninenines`](https://github.com/ninenines) family of projects. | ||
(Others include [`:cowboy`](https://hex.pm/packages/cowboy) and | ||
[`:ranch`](https://hex.pm/packages/ranch), which power Phoenix.) | ||
|
||
`:gun` is battle-tested and fun to use, but the | ||
main feature we wanted gun for is that it is not | ||
[`:websocket_client`](https://hex.pm/packages/websocket_client). | ||
|
||
Prior to Slipstream, we at | ||
[`NFIBrokerage`](https://github.com/NFIBrokerage) used | ||
[`phoenix_gen_socket_client`](https://hex.pm/packages/phoenix_gen_socket_client) | ||
and [`phoenix_client`](https://hex.pm/packages/phoenix_client), which are both | ||
backed by [`:websocket_client`](https://hex.pm/packages/websocket_client). Once | ||
we started using phoenix channel clients in our production | ||
services en masse, we found an odd bug we believe to be a [known | ||
issue](https://github.com/sanmiguel/websocket_client/issues/62) in | ||
`:websocket_client` around the RFC-conformance of close frames. This | ||
closing issue would manifest itself as zombie procesess on the server-side | ||
(specifically, `:cowboy_clear.connection_process/4` processes) which would | ||
never release process memory. | ||
|
||
This isn't likely a common problem for most phoenix websocket client users, but | ||
at the time we were initially testing out a framework for fueling front-ends | ||
and keeping them up-to-date with a library called Haste, which we intend on | ||
open-sourcing soon. Haste uses websockets rather aggressively, connecting and | ||
disconnecting them very quickly and moving large amounts of data over-the-wire. | ||
|
||
In addition to loading pages of data over-the-wire on the websocket connection, | ||
the `Phoenix.Channel` on the server-side would attempt to determine if changes | ||
made in the database would affect rows on a users table. This resulted in a | ||
large numbers of messages being sent to the `Phoenix.Channel`, which prevented | ||
process hibernation, leading to a very large process memory. The stacking up | ||
of this process memory and the zombie-like state these processes were left | ||
in when `:websocket_client` attempted to disconnect would quickly overwhelm | ||
the backend server hosting the data, leading to out-of-memory crashes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters