-
Notifications
You must be signed in to change notification settings - Fork 520
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
Support async RESP responses to pending GET calls (due to disk read) #387
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.
awesome to see this being investigated, and I fully understand this is very early! probably the main thing to describe somewhere is: what exactly is the expected usage, in particular what this means in terms of connections and RESP flow. Who sends and receives what, etc - and on which connection (out-of-band kinda demands 2 connections, or RESP3). Happy to help poke with sample client usage as this develops - I'll keep a watch, but feel free to ping me.
How to test out-of-band responses
Request:
Reply:
Request:
Reply (sync):
Reply (async):
Request:
Reply:
|
I have clarified that this is specifically for async responses on the SAME client-server connection. Creating a separate connection to send responses "out-of-band" is not scalable for the intended use case, so we will not pursue that. When user sends a Needless to mention, we guarantee that the async response will not break in between a sync response to a different command issued on the same connection, while we were waiting for the async to complete in the background. The only exception to this is the |
IMO that single-connection approach **cannot** be done safely before RESP3,
which adds a token prefix to specify an out-of-band message. I do not
believe it is 100% safe or reasonable to hand-wave a "that looks like it
*might* be an async response, treat it as such"
…On Thu, 16 May 2024, 22:37 Badrish Chandramouli, ***@***.***> wrote:
awesome to see this being investigated, and I fully understand this is
very early! probably the main thing to describe somewhere is: what exactly
is the expected usage, in particular what this means in terms of
connections and RESP flow. Who sends and receives what, etc - and on which
connection (out-of-band kinda demands 2 connections, or RESP3). Happy to
help poke with sample client usage as this develops - I'll keep a watch,
but feel free to ping me.
I have clarified that this is specifically for async responses on the SAME
client-server connection. Creating a separate connection to send responses
"out-of-band" is not scalable for the intended use case, so we will not
pursue that.
When user sends a GET command that hits disk, and async is turned on for
the session, the server will immediately reply with -ASYNC token. At some
point in the future, the server will send the async response packet back
on the same connection.
Needless to mention, we guarantee that the async response will not break
in between a sync response to a different command issued on the same
connection, while we were waiting for the async to complete in the
background.
—
Reply to this email directly, view it on GitHub
<#387 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEHMDDIOEOYQWVCUBI3TDZCURLJAVCNFSM6AAAAABHZAFA4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJWGIZTENJSGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Oh, sure, we can do what it takes for this to be RESP3 compatible (as long as it's not going to add overhead on the critical path or too much work). I just followed the protocol as I understood it from your issue. Any link to exactly what needs to be done? As mentioned, I'm not seeing how we can reasonably expect clients to double the number of connections to the server just for this. |
OK; RESP3; the absolute minimum you'd need here would be:
Now; strictly speaking there's actually a whole bunch of other things that change between RESP2 and RESP3 with differing levels of documentation - there's a whole story there, and the final "here's the changes in one place" never actually got merged, you can see it here: https://github.com/redis/redis-doc/pull/2513/files - however, to be honest, I suspect you can largely limp by without those secondary changes; the reason I say that is:
SE.Redis copes fine with either layout, for example. I cannot say that every client will be fine if that client has hard-coded RESP3 vs RESP2 response handling. |
As first step, added basic |
Will look ASAP. Important: I missed another RESP3 change: if Garnet
supports pub/sub, then on RESP3 connections:
1. subscribe is allowed *alongside* normal commands (they are no longer
modal)
2. when publishing, the distribution to connections uses the "push" type if
an individual connection is RESP3, rather than the array type
…On Sat, 18 May 2024, 01:44 Badrish Chandramouli, ***@***.***> wrote:
As first step, added basic HELLO support here: #398
<#398>
—
Reply to this email directly, view it on GitHub
<#387 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEHMDYV2ZBN4VOTQ2XVYLZC2P7PAVCNFSM6AAAAABHZAFA4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJYGUZTENZZGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I can confirm that I can connect as RESP3 (although I have not done exhaustive tests), and I've started a very early spike here: https://github.com/StackExchange/StackExchange.Redis/tree/marc/async - zero relevant testing yet |
…o badrishc/async-resp
…rnet into badrishc/async-resp
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.
Approved with some minor comments
…icrosoft#387) * Initial rough prototype checkin * updates to logic * update comment for spinLock * fix formatting * add comments * Basic implementation of HELLO command * Added command info for HELLO + added website docs * update SE.Redis to latest, add HELLO unit test * Add and use EqualsIgnoreCase * use nameof(RespCommand.HELLO) * support special pong in RESP2 subscribe * only support RESP2 in this PR * remove resp3 testcase * make EqualsIgnoreCase extension method in utils * improve the case-insensitive match test * support push subscribe * update version * fix lowest flag * fix info commands * ensure full input received before processing array commands, if useAsync is true. * async only works on RESP3 or later * change respProtocolVersion to byte * add comments * protocol change is not allowed with pending async operations * optimize sync case * fix format * fix push response header for async * fix asyncStarted increment * Added unit test, minor fixes * Cancel and signal to ensure the async processor ends
Supports the following:
async on
command to turn on async mode for sessionasync off
command to turn off async mode for sessionasync barrier
command to complete all ongoing pending ops on that sessionLimitations:
HELLO 3
)GET
operation right now, when theGET
hits disk (goes pending)Protocol summary:
-ASYNC token
toGET
that goes pendingPUSH
RESP3 reply on the same stream (TCP connection) as per the format in the linked proposal by @mgravellFixes #157
Open tasks: