Tuesday, August 14, 2012

Block Blob Vs. Page Blob

Windows Azure storage services provide ability to store large binary files using Blob storage. So if I have a large binary file which I want to store on Azure I can use the Blob Storage.

But now comes a tricky part. There are 2 types of blob storage available on Azure viz. you can store a large file as a Block Blob or a Page Blob.

The scenarios in which to use Page Vs. Block Blob according to MSDN documentation here is that Block Blobs are to manage the upload of large files in parallel while Page Blobs are good for Random read and write operations on a Blob. This one went right over my head.

What if I have a conflicting scenario e.g. I have a huge VHD file which I want to be uploaded in parallel and once uploaded do random read and write on it as needed. So I am not really sure which one should I use in such a case. I guess I would go for the Page Blob because upload is a one time operation for VHD file and after that my hypervisor will keep modifying the file for the life of the file. So it is more important that the random read and write operations are faster then the upload speed.

The technical difference can be summarized in the below table

Factor

Block Blob

Page Blob

Max Size 200 GB 1 TB
Chunk Size Each Block can be 4 MB Each Page can be 512 Bytes
Write Operation Multiple blocks can be modified and then a Commit Operation commits the modifications in a single go The write operations happens in place and the commit is done then and there rather then waiting for a separate.

So all in all.

Parallel upload == Block Blob

Random Read Write == Page Blob

Hope this helps

¬Abhishek

2 comments:

Shawn Molloy said...

Good post; I was totally confused even after reading the MSDN article on block VS page blocks. It doesn't give a justifaction for doing page blobs.

I feel like Microsoft should have put more thought into the blob storage api, for example from version 1.0 to 2.0 so many breaking changes; couldn't they have done it right the first time?

I also feel like this Block VS Page blob problem will be addressed in the future by completely eliminating page blobs. Just a guess.... but knowing Microsoft, they would deprecate it.

Unknown said...

you wrote the maximum page size to be 512 bytes. Can it be any multiple of 512 bytes e.g. 4 MB??