Skip to content
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

[INSPIRATION ONLY] - pseudo-implement asynchronous request-reply design [DO NOT MERGE] #1490

Closed
wants to merge 18 commits into from

Conversation

thomasyu888
Copy link
Member

@thomasyu888 thomasyu888 commented Sep 4, 2024

Problem
There are endpoints that take > 1 second to return a response, it is best practice for API endpoints for these to return fast

Solution
Use celery + redis and the async request reply design pattern. https://learn.microsoft.com/en-us/azure/architecture/patterns/async-request-reply. NOTE: this PR does not fully work, but it meant to showcase some tech that can be used.

What didn't work about this PR was the connection between redis and celery in the docker containers locally.

Here's a rough sequence diagram that may not be fully correct (ie the status codes, etc)

image

@thomasyu888 thomasyu888 changed the title For inspiration only - use celery + redis for asynchronous request-reply design for API's that serve long running processes [INSPIRATION ONLY] - Asynchronous request-reply design for API's that serve long running processes Sep 4, 2024
@thomasyu888 thomasyu888 changed the title [INSPIRATION ONLY] - Asynchronous request-reply design for API's that serve long running processes [INSPIRATION ONLY] - Asynchronous request-reply design for API's that serve long running processes [DO NOT MERGE] Sep 4, 2024
@thomasyu888 thomasyu888 changed the title [INSPIRATION ONLY] - Asynchronous request-reply design for API's that serve long running processes [DO NOT MERGE] [INSPIRATION ONLY] - pseudo-implement asynchronous request-reply design [DO NOT MERGE] Sep 4, 2024
@linglp
Copy link
Contributor

linglp commented Sep 5, 2024

@thomasyu888 very interesting. I looked into turning schematic APIs to async a long time ago when we were still doing tiger team, and also saw celery + redis pattern. I could do more research into this too.

@afwillia
Copy link
Contributor

afwillia commented Sep 5, 2024

@thomasyu888 how did you make this diagram?

@thomasyu888
Copy link
Member Author

thomasyu888 commented Sep 5, 2024

Thanks both for looking at this!

@linglp before you dive deeper into this, lets focus on the tasks at hand and we can align as a group what gets tackled next

@afwillia See this. That said, you can write a GPT prompt like this:

I am a software architect and I would like to generate the markdown code for mermaid sequence diagram for the below code (paste the code)

@BryanFauble
Copy link
Collaborator

⚠️ To be aware of if looking to implement this ⚠️

If we implement an async job queue in front of schematic. Now schematic would intentionally have request-to-request persistence. We would likely want to match the sub in the JWT claim to the status of the job they're requesting to make sure they match. This is to ensure we are properly having an authorization check in place to prevent user "A" from requesting information about the job of user "B".

Base automatically changed from fds-305-table-operations to develop September 9, 2024 15:43
@thomasyu888 thomasyu888 deleted the tyu-tracing-test branch November 1, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants