-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add autoPing
for web sockets (ember server).
#7348
base: series/0.23
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hovewer, actual ping is not materialized in
WebSocketBuilder2.build
, for performance reasons:
Hmm, is this a compatibility issue: if we release this feature without a default implementation, what happens to all the servers that have not implemented yet?
If possible, we should implement the feature directly in WebSocketBuilder2.build
. If there is a measurable difference in performance, then we can override it in servers implementations with a more efficient implementation.
server/shared/src/main/scala/org/http4s/server/websocket/WebSocketBuilder.scala
Outdated
Show resolved
Hide resolved
server/shared/src/main/scala/org/http4s/server/websocket/WebSocketBuilder2.scala
Outdated
Show resolved
Hide resolved
core/shared/src/main/scala/org/http4s/websocket/WebSocketContext.scala
Outdated
Show resolved
Hide resolved
core/shared/src/main/scala/org/http4s/websocket/WebSocketContext.scala
Outdated
Show resolved
Hide resolved
core/shared/src/main/scala/org/http4s/websocket/WebSocketContext.scala
Outdated
Show resolved
Hide resolved
As for performace difference: val n = 10_000
val m = 100
val s = Stream(1).covary[IO].repeatN(n)
val s2 = s.mergeHaltL(Stream.empty)
s.compile.last.replicateA_(m).timed.map(_._1.toMillis).flatMap(IO.println) >>
s2.compile.last.replicateA_(m).timed.map(_._1.toMillis).flatMap(IO.println)
Also, please take a look at this PR , where replacing Baking a default implementation of auto-ping into |
dddb20b
to
875a975
Compare
… Ember server rolls its own auto-ping.
@armanbilge please take a look: a default auto-ping implementation in |
What if we collect the |
How to do a natural transformation EDIT: done. |
@armanbilge What do you think? |
autoPing
flag is added toWebSocketBuilder2
(auto-ping should be arguably configurable per web socket connection).Hovewer, actual ping is not materialized inWebSocketBuilder2.build
, for performance reasons: concurrent merging of 2 fs2 streams (business logic and pings) is much more expensive than writing theping
frames directly into the socket.WebSocketBuilder2.build
provides a default (albeit less performant) implementation of auto-ping. Servers have the ability to override this implementation with a more performant direct write into the socket.Closes #7347.