Skip to content

Commit

Permalink
fix: make websockets non-blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
npaton committed Oct 5, 2023
1 parent 297d560 commit 75216cc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .changeset/websockets-non-blocking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"@empirica/core": patch
---

Make the websocket connection non-blocking. This fixes issues where a zombie
websocket connection (not disconnected, but not keeping up with the messages
sent) could lock up the server. What we call zombie connections can happen when
a client is either totally non-responsive, or when the client is too slow to
process messages. Now, we will queue up to 500 messages per GraphQL
subscription, and if the client does not keep up, we will drop the connection.

This also makes websocket sends non-blocking, so we are no longer sending as
slowly as the slowest connection. This should greatly improve performance for
most clients that have a good connection. For clients with a bad connection,
they will still be slow, there is not much we can do about their internet
connection. But they will not slow down the server for everyone else. And we
have clear limits on how many messages we will queue up for them, so their
connection will reset after a while, which could help them reconnect and get a
better connection.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/charmbracelet/lipgloss v0.5.0
github.com/cortesi/moddwatch v0.0.0-20210323234936-df014e95c743
github.com/davecgh/go-spew v1.1.1
github.com/empiricaly/tajriba v1.4.0
github.com/empiricaly/tajriba v1.4.1
github.com/go-playground/validator/v10 v10.11.0
github.com/jpillora/backoff v1.0.0
github.com/json-iterator/go v1.1.12
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/empiricaly/tajriba v1.4.0 h1:BPXa3JcuaLGebZ18dDOxXf6PpWbJanzrJylebpxErUQ=
github.com/empiricaly/tajriba v1.4.0/go.mod h1:TqAM0iRbN78gE5vnZ1Ot6PQOidfYM5FwIdoU/UB+wrE=
github.com/empiricaly/tajriba v1.4.1 h1:ki2Y+3ljg832n37X37Lj/VLuFSoLZc6GF7cmTviMkY4=
github.com/empiricaly/tajriba v1.4.1/go.mod h1:TqAM0iRbN78gE5vnZ1Ot6PQOidfYM5FwIdoU/UB+wrE=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
Expand Down

0 comments on commit 75216cc

Please sign in to comment.