Windows azure cost Architecture

Source: Internet
Author: User

Technet magazineArticleHttp://technet.microsoft.com/zh-cn/magazine/gg213848.aspx

Cloud computing and platforms such as Windows azure are publicized as the "next major theme" in the IT industry ". It seems impossible to think of cloud computing with thousands of advantages.

You can use computing and storage on demand at any time, and only pay for effective use. However, this also brings about a problem. If you want to design a common applicationProgramThe cost of designing a cloud application may not be optimistic.

Different metrics

In the traditional IT industry, IT personnel will purchase a set of hardware (such as network infrastructure and servers), set it, execute the configuration process, and connect it to the Internet. This is a one-time investment, with employees controlling "Knob" and "Bolt"-That's it.

For cloud computing, the cost model replaces the investment model. Pay for such resources based on the effective use of server functions and storage. For cloud platforms such as Windows Azure, you can use the following measurement values to calculate the monthly fee:

    • Retention of VM hours-indicates that the deployed application is charged even if the application is not currently running
    • Number of CPUs in the VM
    • Bandwidth (in the unit of each incoming/outgoing GB)
    • Storage used (in GB)
    • Number of transactions stored
    • Database size in SQL azure
    • Connections in Windows azure appfabric

You can find all pricing details on the Windows azure website microsoft.com/windowsazure/offers. From the list above, we can see that there are many factors to consider.

Restrict virtual machines

The following is a practical analysis. Limiting the number of VMS running is a good way to save costs, but for Web roles, it is best to have at least two available VMS for load balancing. Use the Windows azure diagnostic API to measure the CPU usage, HTTP Request volume, and memory usage of these instances and reduce the application size as appropriate.

Every instance of any role running on Windows azure every month doubles the hours on the bill. For example, running an average of three role instances (sometimes two or four) is 25% cheaper than running four instances at a time without any workload.

It is also recommended that you have at least two role instances for background processing. This helps ensure that the application is still available when one of the role instances fails and needs to be updated or restarted. You can use the tools provided by Windows azure to directly configure a job role to be dedicated only for executing a specific task.

For example, if you are running a photo sharing website, you need to use a worker role to resize the image and use another role to send email notifications. Following the "at least 2 instances" rule will mean running 4 worker-role instances, which will produce a considerable fee. Adjusting the image size and sending emails does not actually occupy the CPU. Therefore, only two worker roles should be enough to complete these two tasks. For running Windows Azure, this will save 50% of the monthly cost. It is quite easy to implement the thread mechanism in the worker role so that each thread can execute the work it is specially responsible.

Windows azure provides the following four types of VMS: small, medium, large, and super large. The difference between different sizes is the number of available CPUs, available memory and local storage, and I/O performance. Before deploying a VM for Windows Azure, you 'd better know the appropriate VM Size. Once the application starts running, the size cannot be changed.

When you receive the monthly list, you will notice that all computing hours are converted into small instance hours on the bill. For example, the hourly rate of a medium-sized computing instance is shown as two hours for a small computing instance. If you are running two medium-sized instances, you will be charged for 720x2x2 hours.

Consider this factor when adjusting the VM Size. You can use small instances to achieve almost the same computing power. If you have four small instances, you will be charged for 720x4 hours. The price is the same. You can scale down to two instances at an appropriate time, that is, pay by 720x2 hours. If you do not need more CPU, memory, or storage, stick to the small instance because the adjustment level of the small instance is more refined than that of the large instance.

The Windows azure service starts billing when you deploy an application, regardless of whether the role instance is active or disabled. The Windows azure portal is clearly described. This portal has a large image frame. "When the box is displayed in gray, you can rest assured. Billing starts when the box is displayed in blue ." (Thanks to Brian H. Prince for this pretty joke .)

When you deploy an application to a temporary or running environment and disable it after use, do not forget to cancel the application deployment. You do not want to pay for any non-active applications. In addition, remember to scale down the application as appropriate. This will directly affect the monthly operating costs.

When adding and downgrading applications, it is best to make a role instance run for at least one hour, because you are charged by the hour. Create multiple worker threads in the worker role. In this way, the worker role can execute multiple tasks, instead of simply executing one task. If you do not need more CPU, memory, or storage, please stick to the small instance. Again, make sure that the deployment is canceled when you do not use the application.

Bandwidth, storage, and transactions

Bandwidth and transactions are two complicated measurement standards. In addition to viewing the monthly fee, there is currently no good way to measure this data. You can view and adjust the real-time monitoring of your application. Bandwidth is easier to measure among the two measurements. The less network traffic is used, the lower the cost. That's simple.

It is complicated to deploy applications in multiple Windows azure regions. Assume that you run the Web role in the North America region and run the storage account in the western Europe region. In this case, the bandwidth used for the communication between the Web role and the storage will be charged.

If both the Web role and storage are in the same region (for example, both in North America), communication between the Web role and storage will not incur bandwidth fees. Remember, when designing a remote distributed application, it is best to make the services used together in the same windows azure region.

When using Windows azure Content Delivery Network (CDN), you can take another interesting measure to reduce costs. CDN uses the same billing method as blob storage, that is, billing is based on the amount of storage per GB per month. After a request is sent to CDN, it obtains the original content (including the billed bandwidth consumption) from blob storage and caches it locally.

If you set the cache expiration time to too short, it will consume more bandwidth because the CDN cache will perform self-update more frequently. If you set the cache expiration time too long, Windows azure will extend the time for content to be stored in CDN and charge by the amount of storage per GB per month. Consider this factor for each application to determine the optimal cache expiration time.

Windows azure diagnostic monitor also uses blob storage for diagnostic data, such as performance counters, trace logs, and Event Logs. It writes this data to your application at a specified interval. Writing per minute will increase the transaction count in storage, resulting in additional costs. Setting the write interval to 15 minutes Reduces storage transactions. However, there is a drawback that the diagnostic data will always be at least 15 minutes ago.

In addition, Windows azure diagnostic monitor does not clear its data. If you do not clear data yourself, you may have to pay for the storage of many diagnostic data that only contains old and expired data.

10.000/transaction billing. This number may look very high, but you actually have to pay for the transaction. Each operation in the storage account is a transaction. Create a blob container, list the content of the Blob container, store the data in the table store table, browse messages in the queue-all these are transactions. For example, when you perform operations such as blob storage, you first check whether the Blob container exists. If it does not exist, you must create one and store one blob. This is at least two (maybe three) transactions.

This counting method also applies to carrying static content in blob storage. If your website carries 40 small images on one page, it is equivalent to 40 transactions. This can increase rapidly with high-traffic applications. You can reduce the number of transactions by almost 50% by simply ensuring that the Blob container exists at application startup and skipping check for each subsequent operation. By doing so, you can reduce the cost.

Indexing may be expensive

SQL Azure is an interesting product. You can purchase 1 GB, 5 GB, 10 Gb, 20 GB, 30 GB, 40 Gb or 50 GB databases at an extremely low monthly price. You can purchase a 5 gb SQL azure database directly, which is very safe. Even if you only use 2 GB of capacity, it is not a pay-as-you-go model, right?

In some cases, distributing your data to different SQL azure databases may be more cost-effective than using a large database. For example, you can use a 5 GB database and a 10 Gb database instead of a 20 GB database containing 5 GB of unused capacity. If you cleverly process this type of policy storage and this storage method applies to your data type, it will be very good for you to reduce the cost.

Each object occupies storage space. Indexes and tables may occupy a large amount of database storage capacity. Large tables may occupy 10% of the database, and some indexes may occupy 0.5% of the database.

If you divide the monthly cost of SQL azure subscription by database size, a unit that calculates the cost by storage. Consider the objects in your database. If index x costs 50 points per month and does not actually significantly improve performance, you only need to discard it. Although not much about $ half, if you delete some tables and some indexes, the sum of these many half dollars is a considerable amount. You can find an interesting example related to this in the blog "actual indexing costs" (blogs.msdn.com/ B /sqlazure/archive/2010/08/19/10051969.aspx) of the SQL azure team.

There is a huge change in application development, that is, no longer using stored procedures in the database, but using object relational ing programs for data in the application logic and performing a large amount of computing.

This is not a problem, but it is interesting to consider windows azure and SQL azure. Running data computing in an application may require other Web roles or worker role instances. If you use SQL azure to perform these calculations, you will save one role instance in this case. Because SQL Azure is billed Based on storage conditions rather than CPU usage, you can actually get a free CPU cycle in the database.

Developer impact

WriteCodeDevelopers have a direct impact on costs. For example, when building an ASP. Net website hosted by Windows Azure, you can use the Windows azure backup storage session Status provider to distribute sessions among instances of different roles. This provider stores session data in the Windows azure table service. The storage volume, bandwidth usage, and transaction count used in the table service are measured for billing. See the following code snippet used to determine the user language in each request:

Copy code

If (session ["culture"]. tostring () = "En-us "){//.. set to English ...} if (session ["culture"]. tostring () = "NL-be "){//.. set to Dutch ...}

No problem? Technically, there is no problem, but you can optimize it from the cost perspective to reduce the cost by 50%:

Copy code

 
String culture = session ["culture"]. tostring (); If (Culture = "En-us "){//.. set to English ...} if (Culture = "NL-be "){//.. set to Dutch ...}

The two code segments have the same functions. The first code segment reads session data twice, while the latter only reads session data once. This means that the latter will save 50% of the cost in terms of bandwidth and transaction count. This is also true for queues. Reading a message once and 20 times is much more expensive than reading 20 messages at a time.

It can be seen that cloud computing brings different economic and pricing details to carry applications. Compared with traditional data centers, cloud computing can be a major improvement in operational costs. However, when designing the cloud, you must pay attention to some precautions in the application architecture.

Maarten balliauw is a technical consultant in the Web technology field of realdolmen (Belgium's largest ICT company. He focuses on ASP. net mvc, PHP, and Windows azure. He is Microsoft's most valuable ASP. NET expert and has published many articles in the PHP and. Net documents, such as the msdn magazine, Belgium, and PHP architect. Balliauw often gives speeches at various national/regional and international activities. Visit blog. maartenballiauw. Be to view his blog.

Related Article

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.