Comparison of data storage and performance in Windows azure (1)

Source: Internet
Author: User

 

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.

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.