Replies: 5 comments 1 reply
-
|
@hubcio How would one start to implement this? |
Beta Was this translation helpful? Give feedback.
-
|
Just to add: this functionality will allow to implement actual blocking poll, where poll interval wouldn't really matter - consumers could hang indefinitely on |
Beta Was this translation helpful? Give feedback.
-
|
Kinda late contribution, but I would like to keep this discussion alive, as I have idea how this potentially could be implemented in a way where it's extensible by the end-user. I think we could turn this mechanism into an "general purpose" notification mechanism. The way I imagine this could work is as follows:
This way we don't have to create our selves all of the possible notifications that users would ask for, instead it's on user to implement whatever notification they wish. |
Beta Was this translation helpful? Give feedback.
-
|
i checked other message streaming platforms. in Kafka they have after analyzing our architecture (both the current single node server and the new VSR we're building), i think the right approach is deferred-response polling - essentially what kafka, redis, and NATS all do. the idea is simple: add wait_timeout_ms to PollMessages. value 0 = current behavior (return immediately). value > 0 = "hold my request until data arrives or timeout expires." one parameter, every SDK already has poll_messages() implemented - this is a single field addition per language. old clients that don't send it get default 0, fully backward compatible. why not push notifications? push (server sends unsolicited frames to client) would require splitting every connection handler into separate reader/writer tasks, new subscribe/unsubscribe commands, frame type discriminator in the wire protocol (breaking change), and every foreign SDK would need a frame demultiplexer with background reader task. that's weeks of work per SDK for the same wake latency. deferred-response gives sub-millisecond wakeup with zero new concepts for users. how it works server-side: the connection handler is not the message pump. each TCP connection has its own handler task, the pump processes ShardFrames sequentially via channels. we don't block the pump - we "park" the poll. when poll_messages with wait_timeout > 0 arrives and partition has no new data, the shard stores a lightweight wakeup handle in a per-partition wait registry. handler returns from process_frame immediately, pump is not blocked and continues processing other frames. when SendMessages commits to that partition, the pump sends a wakeup signal to waiting consumers (one atomic CAS per consumer, natural coalescing). the parked poll completes, client receives data. if timeout expires first, client gets an empty response (not an error, this is normal). this fits the new VSR architecture well - the notification fire point is inside commit_messages() after partition.offset.store(committed_offset). consumers only get woken after data has achieved quorum, never after prepare. view change just lets pending polls expire naturally. the response IS the data - no race between "notification arrives" and "poll for data" that you'd get with push notifications in a consumer group scenario. as for the server internals, when we build the new connection handler we should design it with split reader/writer tasks from day one - not for push notifications, but because it eliminates per-request channel allocation and the select! overhead in the read path. this makes adding push notification support later (for cluster events, rebalance signals, etc.) trivial - just one more message type on the writer task's channel. but the user-facing API stays poll_messages(wait_timeout_ms) regardless. |
Beta Was this translation helpful? Give feedback.
-
|
Yeah I proposed to make it in an extensible way, because there would be more use-cases like this and we wouldn't be able to cover all of those on our own. Also I kinda feel like your solution doesn't necessary solve the problem at hand, because what they user wanted was a notification, not long polling, this gives the user of the SDK higher degree of freedom as what they want to do with it (in most cases it would be using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The usual workflow is polling until I get messages, if I want low latency I have to poll very often, but if my consumer wants to sleep because there is no activity, it's not possible, it would be useful to have the option to notify consumers (not sending messages, just a notification in a tcp stream per example), so the consumer can start polling again.
discord discussion started here : discord.com/channels/1144142576266530928/1144142577369628684/1477810937405898883
From: #2851
Beta Was this translation helpful? Give feedback.
All reactions