WindowsComparison of azure data storage and Performance
There are two ways to store data on Windows azure: Windows azure storage and SQL azure. Storage can be subdivided into blob, table, and queue. In the following, we will make a simple comparison of the storage methods and performance of these methods on azure. For more information, see the following.
1. Blog storage: stores large binary data with a maximum storage capacity of 50 GB.
(1) blob operation example: store a string in blob and read it again.
CloudBlobClient blobclient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobclient.GetContainerReference("blobtest"); container.CreateIfNotExist(); CloudBlob blob = container.GetBlobReference("myFile"); blob.UploadText("Hello World!"); string blobcontent = blob.DownloadText();
(2) Update BLOB data using streams.
Because the blobstream obtained by using openwrite is write-only, you cannot use the seek method to locate the write location. Therefore, if you want to change the content in blob, all data may need to be read to the memory, modified, and uploaded again. If you only append data after an existing blob, this method is less efficient. Two streams are provided to update blob for reference.
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount; CloudBlobClient blobclient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobclient.GetContainerReference("blobtest"); container.CreateIfNotExist(); CloudBlob blob = container.GetBlobReference("myFile"); BlobStream streamWrite = null; try { streamWrite = blob.OpenWrite(); BlobStream streamRead = null; try { streamRead = blob.OpenRead(); byte[] buffer = new byte[32]; int len = -1; streamRead.Seek(1, System.IO.SeekOrigin.Begin); while ((len = streamRead.Read(buffer, 0, buffer.Length)) > 0) { streamWrite.Write(buffer, 0, len); } string appendContent = "This is example."; byte[] bs = Encoding.ASCII.GetBytes(appendContent); streamWrite.Write(bs, 0, bs.Length); } finally { if (streamRead != null) { streamRead.Close(); streamRead = null; } } } finally { if (streamWrite != null) { streamWrite.Close(); streamWrite = null; } }
(3) Comparison of Blob Operation Performance
Performance Curves of BLOB Data appending, updating, and deleting.
BLOB data download performance curve. The figure shows that it may take nearly five seconds to download a 5 MB data.