-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
RPC Server: Make endpoints asynchronous #1706
Comments
Probably for small things, but it could get slow to return the logs all the time... maybe a flag?
Yup, that's the plan! Async tasks work pretty nicely with a process-table model like
For a first pass, I would just hold them in memory until they are requested and then delete them, but I'd longer-term like to "expire" completed results in the |
👍 to a flag
Agree all around. Let's store them in memory until that stops working.
for the sake of cloud scalability, we time out open, unanswered requests after 60 seconds. we should avoid doing long polling all over the place if possible, IMO python isn't that good at handling that type of request load |
Describe the feature
The non-administrative endpoints in the rpc server should be asynchronous. When a request is made, the rpc server should return immediately with an async token. Subsequent requests to the rpc server should be able to check the status of the running task via another endpoint, as well as retrieve task results when the request completes.
The following tasks should be asynchronous:
The following tasks should be synchronous:
Async tokens
When an asynchronous request is made to the server, a
request_token
should be returned in the response. This should be something like a uuid.The new
/poll
endpoint should accept arequest_token
either in the url (eg./poll/:request_token
) or as a query parameter (eg./poll?request_token=abc123
). My instinct is that this should be a POST request, but happy to discuss if something else makes more sense.The /poll endpoint
The
/poll
endpoint should return a dictionary. The following examples show three different schemas for three different task states, but a single schema may be used if that is preferred in the implementation.When the targeted request is running:
When the targeted request has completed successfully:
When the targeted request has completed with an error:
Storing task results
The rpc server cannot store results indefinitely - it would eventually run out of memory! Instead, the rpc server could serialize results & logs.... somewhere. When the
/poll
endpoint is queried for a completed task, the rpc server could load these results from that persistent storage location. See Questions below for a discussion....Questions:
logs
in the/poll
response. Is this a reasonable way to fetch logs from a running task?task_id
used internally (and exposed in theps
/kill
commands) as therequest_token
? That feels sensible to me, but I'm not sure if there are any caveats to be aware of.@cmcarthur, @beckjake, would love to get your thoughts on these!
Describe alternatives you've considered
we could ask users to keep their browsers open on a perfectly stable internet connection ;)
The text was updated successfully, but these errors were encountered: