-
Notifications
You must be signed in to change notification settings - Fork 572
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
Conflation #45
Comments
Somehow I must have forgotten to paste in the footnote that I refer to in the text. So I'll try to reproduce it: [1] This could be implemented by either one of following or some combination, potentially configurable:
|
Quoting my last statement:
This reminds me that calling this feature |
I want this |
@EugenDueck I wonder if all that we should do is add a callback to Then it's up to a higher-level impl to decide on the conflation mechanics. |
That's basically what I'm doing, except that - in my socket.io implementation that I just tested yesterday and it seems fine - I wrap the packets in a new Packet class, which holds and caches
It offers methods Otherwise there'd be a lot of waste in back- and forth-encoding, especially with multicast (rooms) and broadcast. Will try to prepare a engine.io variant of it as soon as time permits. Question: Do you agree that the callback (provided by the app that is using socket.io/engine.io) should not see the on-the-wire representation but the JS object? |
Agreed completely. In fact, in engine.io |
Alright. Will hopefully get a pull-request done later today. Question about the rough timeline. When talking engine.io 1.0, are you talking days, or weeks, or months? |
Days |
Gotcha. One more question about the big picture: As I don't see them in engine.io: stores will stay in socket.io? |
Yep. In fact, that's why I want the reliable messaging layer directly in socket.io. It'd be really cool if processes could die, come and go, yet messages stay in let's say redis. |
Indeed. I'm sorry this is getting even more off-topic, but in terms of the big picture, which it is good to always have when making non-trivial changes: Does (the current and/or the future) socket.io's RedisStore allow to non-sticky sessioned load balancing? (Just haven't had the time to dig into it yet) |
Per discussion, we're moving it into a different module. |
…ble-and-method-parameter-names-should-comply-with-a-naming-convention-fix-1 squid:S00117 - Local variable and method parameter names should comply with a naming convention
I'd like to see
engine.io
support a feature called conflation, i.e. the removal of some messages based on criteria likeSo a more general version of the
volatile
feature insocket.io
.Conflation is especially beneficial to performance of both server and client, when broadcasting and multicasting (e.g. rooms) are frequently used, and protects the server from getting bogged down memory-wise by a single slow consumer who'll cause the buffer to grow to heaven (or until the heartbeat kills the connection, which could still be a lot depending on the msg frequency / heart beat frequency rate and the number of slow consumers). [1]
In case my description above failed to convey the usefulness of conflation, http://magmasystems.blogspot.jp/2006/08/conflation.html has a brief description of that feature and its application to the distribution of price quotes in finance. IBM, too, use conflation for the same purpose: http://publib.boulder.ibm.com/infocenter/imds/v3r0/index.jsp?topic=/com.ibm.imds.doc/welcome.html .
If engine.io wants to enable conflation feature based on the client's performance consuming messages, it has to get support from the engine.io layer, because that feature depends on the client's state (connection open and drained?), which is - understandably - hidden from the application layer. Conflation based on message frequency alone can obviously be done completely in the application layer, as the application has control over how often it calls
emit
and can throttle it without the help of engine.io.There's a rather straightforward way to implement it so that it is both flexible in terms of the conflation logic, yet does not require complex logic inside engine.io itself, and I've actually already implemented it in
socket.io
v0.9.8.Here's a simplified pseudo code diff, leaving out a couple of intermediate steps:
before
io.emit(myJavascriptObject);
transport.write(encodePacket(myJavascriptObject))
after
io.set('conflater', function(messages) { /* for example: */ return [messages[messages.length - 1]]; });
io.emit(myJavascriptObject);
conflationBuffer.push(myJavascriptObject);
.onDrained(function() { transport.actualWriteMessages(encodePackets(io.get('conflater')(conflationBuffer))); }
If no conflater function has been configured during initialization, no buffering or calling
conflater
will be done.The
conflater
message canThe above is simplification of the algorithm is not the whole truth, however: In reality, the functions in socket.io/transport are NOT given the
myJavascriptObject
, as provided by the client, but the already encoded version of it. They only get to seeencodePacket(myJavascriptObject)
. There are 2 good reasons for this:myJavascriptObject
will be encoded only once (inSocketNamespace.packet(..)
)Now, I would not want to hand the encoded message into the application layer for the following 2 reasons:
I have an idea how to solve this in a way that
The question is - is the conflation feature deemed important enough, and is it further considered impossible to implement without adding changing engine.io, as I believe? In that case, I would actually like to prepare a pull request.
The text was updated successfully, but these errors were encountered: