-
Notifications
You must be signed in to change notification settings - Fork 483
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
Many post-receive hooks after post-finish hook #1095
Comments
That's odd and should not be happening in the first place, but I am not able to reproduce this locally. Are you able to reproduce this consistently? Could you also share the entire logs for the upload? |
local_tusd.log So, local_tusd and local_fastapi these are logs when I load file locally. |
Thank you, I will look into this in two weeks. |
I feel like you have two different questions here: Why are there so many post-receive events?In
The reason is that you are sending PATCH requests at a high rate, one about every 50ms, which is likely possible because you are testing on a local network with low latency and high throughput. Anyways, a post-receive event is emitted for every PATCH request at the specified interval (1s in your case) and whenever the request ends, so that for every PATCH request we have at least one post-receive event. However, this also means that when you send a PATCH request every 50ms, you will also get the same amount of post-receive events. I recommend you to reconsider whether you need to send many small PATCH requests versus one big PATCH requests. That is usually the more efficient way to go and would also reduce the number of post-receive events. Why are there post-receive events after post-finish?The last post-receive event is emitted whenever we finish processing a PATCH request, which is also often after we have emitted post-finish. This would explain why we have post-receive after post-finish. I am not sure if there is much we can do about this. At the day of they day, they are asynchronous events, so we cannot guarantee their ordering. I hope this helps! |
Given the information about the PATCH request rate I can also reproduce this locally by uploading to a server running on the same machine with a PATCH request body size of 20MB. There we can see that there is a 1s delay between when the first PATCH request finishes and the first post-receive event is emitted. Some delay is expected, but it would nice if it were lower. |
I also noticed that we send HTTP hook request with a concurrency of 1, which is the default for the HTTP client we are using: I wonder if we should increase this. However, it doesn't seem to affect the behavior we are seeing here in this issue. |
Question
I'm trying to create progress meter for file uploader and using TUS http hooks for that matter.
On my local machine's port 8000 there is a python app, where I receive hooks and update database accordingly (tusd, database and app is on my localmachine).
In the app's log I see that "post-finish" hook is always followed by many "post-receive" hooks. And they are going almost instantly:
Is there any way to stop sending "post-receive" after "post-finish" has been sent? It's not kind of big problem now, but in case of many simultaneous uploads I would have to use cache or change my upload algorithms, because every http request to my backend makes request to database, and that is not good.
From my current knowledge it is easier to turn off sending, than changing the way my backend works.
If I'm wrong, correct me please.
Thank you!
Setup details
Commit: 9801b91
Date: Fri Mar 1 14:22:31 UTC 2024
The text was updated successfully, but these errors were encountered: