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

Support for fully asynchronous humbug reports #8

Open
zomglings opened this issue Jul 23, 2021 · 0 comments
Open

Support for fully asynchronous humbug reports #8

zomglings opened this issue Jul 23, 2021 · 0 comments
Assignees

Comments

@zomglings
Copy link
Member

Currently, users can POST /humbug/reports with sync=true or sync=false.

When sync=true, response is only sent after report is written into database.

When sync=false, response is sent after report is written to redis queue (with fallback to database).

This doesn't result in a significant speedup - the sync=false takes ~83% of the time that sync=true takes:

"bash" "-c" "time for i in {1..100}; do curl -s -H \"Content-Type: application/json\" -H \"Authorization: Bearer 6924ac70-f2b4-4444-a26b-7db8c15bf694\" -X POST https://spire.bugout.dev/humbug/reports -d \"{\\\"title\\\": \\\"Report (postgres) lol\\\", \\\"content\\\": \\\"content 5\\\", \\\"tags\\\": [\\\"a\\\", \\\"b\\\"]}\" >/dev/null ; done"

real    0m35.016s
user    0m0.777s
sys    0m0.343s
"bash" "-c" "time for i in {1..100}; do curl -s -H \"Content-Type: application/json\" -H \"Authorization: Bearer 6924ac70-f2b4-4444-a26b-7db8c15bf694\" -X POST https://spire.bugout.dev/humbug/reports?sync=true -d \"{\\\"title\\\": \\\"Report (postgres) lol\\\", \\\"content\\\": \\\"content 5\\\", \\\"tags\\\": [\\\"a\\\", \\\"b\\\"]}\" >/dev/null ; done"

real    0m42.723s
user    0m0.878s
sys    0m0.279s

(although it may be faster when requests are made concurrently).

I propose we change sync={true|false} to syncMode={async|enqueue|commit}.

If syncMode=async, the report will be published as a background task and the endpoint will immediately return 200.

If syncMode=enqueue, then we will do what sync=false currently does.

If syncMode=commit, then we will do what sync=true currently does.

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

No branches or pull requests

2 participants