Looking at the way this is performing, I’m assuming data is written to the drive when received and appended until complete. IMO, the blobs should be stored in RAM and written to the drive when complete. There are multiple reasons for this.
- A 2MB sequential write is much more efficient than (assuming 8k packet sizes) 250+ separate write operations.
- Most uploads seems to be cancelled, so it most instances no data will ever need to be written to the drive.
- Unnecessary drive writes increases wear and tear, temperature and therefore the risk of failure.
- Unnecessary drive writes increase fragmentation and reduce performance.
- Unless someones downstream bandwidth is faster than their drive, which is unlikely, this would hopefully solve any issues with SMR drive, which will become more and more common IMO as users look for cheap data storage rather than system drives.
The only advantage I can think of for writing partial blobs to the drive is if you want to persist the data so they can be resumed in the event the service shuts down and restarts. But the above points seems to be a massive trade off to enable the restarting of the service, especially as it’s safe to assume that in the event of a service restart you’d lose any race you’re in. I suppose you’d also marginally reduce RAM usage, but that seems like an unnecessary worry on most PCs.