Hi vivek “This means you cannot write information less than 4KB size at a time to the disk.“
Can you elaborate this more? What if the data is less than 4KB , and thats the last operation that would happen before the server gets shut down how does OS handles this?
@magicpotato The update might be of less than 1KB but the amount of data that gets written to the disk will always be in multiples of 4KB. This is because a sector consists of 4 KB size.
Also, the server might shut down before the operation is completed on the disk. For the same reason, we have Write Ahead Logging.
But I don't think this replicates the exact scenario of an HDD write, as OS can still buffer the and reorder writes to optimize for physical disk performance. Also there are abstraction layers like JVM, OS etc. in between which would affect programs ability to simulate same scenario.
C language might closer in replicating this scenario exactly.
Also it'd be great if you can also shed some light on SSD side of things as that'd be an interesting read too.
Hi vivek “This means you cannot write information less than 4KB size at a time to the disk.“
Can you elaborate this more? What if the data is less than 4KB , and thats the last operation that would happen before the server gets shut down how does OS handles this?
@magicpotato The update might be of less than 1KB but the amount of data that gets written to the disk will always be in multiples of 4KB. This is because a sector consists of 4 KB size.
Also, the server might shut down before the operation is completed on the disk. For the same reason, we have Write Ahead Logging.
I highly recommend reading this blog which would clarify your doubts: https://vivekbansal.substack.com/p/database-internals-write-ahead-logging
Thanks for the article Vivek, great read.
But I don't think this replicates the exact scenario of an HDD write, as OS can still buffer the and reorder writes to optimize for physical disk performance. Also there are abstraction layers like JVM, OS etc. in between which would affect programs ability to simulate same scenario.
C language might closer in replicating this scenario exactly.
Also it'd be great if you can also shed some light on SSD side of things as that'd be an interesting read too.