Pages

Sunday, October 24, 2010

Azure Pricing vs Amazon AWS Pricing Comparison


How does Azure stack up against its main rival, Amazon, in pricing?

Compute Instances

The standard compute instances sizes are very similar on both platforms – Small (1 core processor, 1.7GB RAM) , Large (4 core processors, 7GB RAM), Extra Large (8 core processors, 15GB RAM ). The only differences being that Azure offers slightly larger drive space on the Large and Extra Large instances, on the Large instance Azure provides 1TB of space vs 0.85TB on AWS , and on the Extra Large instance Azure offers 2TB vs 1.8TB on AWS. However this is probably a minor issue to most cloud platform users who will be more interested in the persistent storage offered (see below).
Azure includes a Medium instance which provides 2 core processors, 3.5GB RAM, 500GB hard disk and is a useful bridge between the Small and Large instances for growing applications.
In addition, Amazon offers a variety of larger instances. High Memory instances provide 17GB – 64GB of memory and High CPU Instances provide up to 20 ‘compute units’ (which equates to 20 cores of processing power).
Pricing for compute instances is identical on AWS and Azure.
Compute instance pricing on AWS and Azure:Small : $0.12 per hour
Medium : $0.24 per hour  (Azure only)
Large : $0.48 per hour
Extra Large :  $0.96 per hour
(NB : All AWS pricing is based on Windows instances, Linux based instances are typically 30% cheaper)
Amazon is currently running a pilot program to transfer Windows Server licenses to EC2. Under this program, pricing for the EC2 instances drops 30% to the Linux EC2 levels. See full details of the Windows Server Mobility program.
The basic pricing models for both AWS and Azure are very similar, however in addition to the standard pricing model Amazon offers Reserved Instances. A reserved instance involves payment of a one time up-front fee that ‘reserves’ an instance which is then available at a lower hourly cost. Instances can be reserved for one or three year terms and pricing varies according to instance size and length of the reservation.
For an assessment of the pricing impact I have amortized the upfront payment equally over the term of the reservation (assuming 12 months usage at 730 hours per month). For example, the one time fee to reserve a Small Instance is $227.5 and thereafter usage on the instance is charged at $0.05 , thus assuming full utilization of the instance the $227.5 payment is $0.026 over the year (227.5 / 12/ 730) and the total hourly cost of the instance is $0.076 (a saving of 37% over the normal charge of $0.12 per hour). If the instance was reserved for three years the charge would be $350 and the final cost would be $0.0.61 per hour.
Amazon AWS Reserved Instance Pricing (Assuming Full Utilization) :Small : $0.076 (1y term) , $0.061 (3yr term)
Large : $0.304 (1y term) , $0.253 (3yr term)
Extra Large :  $0.608(1y term) , $0.507 (3yr term)
All charges are per hour
Amazon also offers spot pricing, which is hourly updated pricing for instances that cannot be booked for any period longer than an hour which  is essentially live market pricing for instances. This is likely only to have very niche appeal for apps which can be run at any time – large batch processing tasks could conceivably use this pricing service.

Storage

Cloud apps need to use persistent storage for files (such as images, videos etc) which are then referenced in the app. Both Amazon’s S3 (Simple Storage S0lution) and Azure Storage price storage at $0.15 per GB, however S3 offers discounts for very large data amounts stored (for example, $0.140 per GB for 50TB – 400TB of storage).
Transactions on both Aaure and AWS are billed at $0.01 per 10,000 transactions, it should be noted there is a slight difference in this as S3 only charges for requests for stored items whereas Azure charges for inward storage transactions as well.
For the Azure CDN versus Amazon’s CloudFront, see our separate article on Azure CDN Pricing .

Data Transfers

Under traditional hosting this would be called bandwidth but the convention for cloud providers is to use the term Data Transfers.
F0r both Azure and AWS, Data Transfer is charged at $0.10 per GB of inbound traffic and $0.15GB per GB for outbound traffic. Azure pricing is constant for all volumes whereas AWS provides discounts for large volumes of outbound traffic – $0.11 per GB for > 40TB ,  $0.09 per GB for >100TB , $0.18 per GB for >150TB.
Prior to June 30, 2010 AWS offers free inbound data transfer and Azure offers free inbound off-peak data transfer.

Databases

Database offerings for Azure and AWS are structured very differently and for that reason are not directly comparable. Amazon’s AWS does not offer  per  database plans and fro SQL Server  you can only use a SQL Serve license to install a full instance of SQL Server on an EC2 instance , or you can use the free SQL Server Express. Azure, by contrast, only offers individual databases of the SQL Server based SQL Azure.
Amazon offers relational database (MySQL) instances which are comparable to EC2 instances with a full MySQL instance installed (and can therefore have numerous databases).
SQL Azure databases are priced at $0.014 per hour for a  database with 1GB of storage and $0.14 per hour for a 10GB database. A 50GB database for SQL Azure has been announced and will be available from June 2010.
By contrast, Amazon’s Small Relational Database Instance has 1.7GB RAM and a single core processing unit which is charged at $0.11 per hour. Storage is charged at $0.1 per GB per month and an instance can have between 5GB and 1TB of storage.
AWS database instances can scale all the way up to the Quadruple Extra Large DB Instance which has 64GB RAM ,  with 26 compute units and 1TB storage.
Both Amazon and Azure offer non-relational databases which are considered persistent storage and charged accordingly (see above).

Packaged Pricing

The obvious question any user will have is what will be the total cost to run the app on the cloud. To this end Microsoft has two offerings which provide a package of resources available at a single monthly charge (overages are charged at the standard rates). By contrast Amazon only offers al-la-carte pricing.
The Azure Development Accelerator Core is charged at $59.95 per month for a six month subscription and provides:
  • 1 month of utilization for a Small compute instance
  • 10GB of persistent storage plus  1,000,000 storage transactions
  • Data Transfer – 14GB outward, 7GB inward
A comparable setup on Amazon would be $95 if the EC2  instance is not reserved, $61.5 if the instance is reserved for one year and $52 if the instance is reserved for three years.
The Azure Development Accelerator Extended is charged at $109.95 per month and is identical to  the Accelerator Core package with a 10GB SQL Azure database included, and this package therefore doesn’t lend itself to a comparison with Amazon AWS.

Conclusion

Across all the services the pricing for Azure and Amazon AWS is very similar, however there are three key differences :
  • Databases - Azure only offers a per database pricing, whereas Amazon offers full database instances. As Azure offers the SQL Server based SQL Azure database this is a more full featured and more expensive alternative to Amazon’s MySQL based offering.
  • Reserved Instances – Amazon allows for an upfront payment to reserve an instance for one or three years which results in a substantial (37% – 50%) saving if the instance is used for the full period.
  • Packages - Azure offers a package of services at a single monthly charge which results in a 50% saving of the regular prices.
NB In this review I have ignored services which have no natural equivalent such as the Azure AppFabric services, or the Azure Asian bandwidth charges for Azure instances location in Asia (AWS instances do not have a geolocation feature).

How to Migrate SQL Server Database To SQL Azure


SQL Azure is essentially a cut down version of SQL Server and so we would expect that migrating from SQL Server to SQL Azure should be a straightforward task. However, in the first release of SQL Azure, the scripts generated by SQL Server Management Studio will require some extra cleanup since not all the SQL Server 2008 features are supported in SQL Azure.
For this demo we will use SQL Server Management Studio (SSMS) to generate the SQL scripts and
migrate an existing database from SQL Server 2008 to  SQL Azure. It should be noted that there are several tools such as the SQL Migration Wizard for assisting in the migration, but in this article we will look at performing a manual migration.
Since SQL Azure is built from SQL Server 2008, the database should first be migrated to SQL Serer 2008 if necessary (note – it is not necessary to update to 2008 R2).
  1. Open SQL Server Management Studio (SSMS), right-click on the database node of the database to be migrated (AdventureWorks for this demo) and select Tasks > Generate Scripts , then select the database to be migrated and click Next:
    ScreenHunter 01 Mar. 05 11.11 Migrating A SQL Server Database To SQL Azure
  2. In the Choose Script Options page, we need to configure the script to comply with the restrictions of SQL Azure, so make the following changes:
    • Convert UDDTs to Base Type: Set this  to true as SQL Azure does not support user-defined types. UDDT’s need to be converted into SQL Azure portable types.
    • Script extended properties: Set to false as SQL Azure does not support extended properties.
    • Script USE DATABASE: Set to false as SQL Azure does not support the USE statement.
    • Script Data: Set to false since we are not migrating the data right now.
  3. In the Choose Object Types page – select all the objects except User Defined Data Types and click Next:
    ScreenHunter 03 Mar. 05 11.27 Migrating A SQL Server Database To SQL Azure
  4. In a succession of screens you will be prompted to select the Stored Procedures, Views, Tables etc to be migrated (depending on which objects are in your database). ClickSelect All then Next for each.
  5. Finally at the Output Option page select where the script should be generated (in this example I have elected to have the script generated in a new query window):
    ScreenHunter 04 Mar. 05 11.39 Migrating A SQL Server Database To SQL Azure
  6. Click Next and SSMS will direct you to the Summary page before generating the scripts in a new SQL script window. The Generate Script Success screen shows the progress and results of the migration on the database objects (see below). Copy the script generated to the clipboard.
    ScreenHunter 05 Mar. 05 11.43 Migrating A SQL Server Database To SQL Azure
  7. Log in to the Azure platform portal at https://sql.azure.com/ and create a target database on the online portal (simply click Create Database after navigating to the the SQL Azure tab and then select the database size).
  8. Close and re-open SSMS to connect to SQL Azure and view your database (seeConnect to SQL Azure from SSMS for details if neceesary) . Note – SSMS in SQL Server 2008 R2 can view the SQL Azure objects and should be used whenever connecting to SQL Azure.
  9. Copy the script into a new script window in SSMS. Before we run the script against the target SQL Azure database we still need to make some modifications to the script:
    • SQL Azure’s first release does not support partitions. Therefore the KEY constraint statement for the table-creation scripts has to be removed and replaced by a separate script. For example, in the original script SSMS generated for creating a data table there are KEYconstraints such as
      PRIMARY KEY CLUSTERED
      (
      [TerritoryID] ASC
      )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
      ) ON [PRIMARY]
      This needs to be replaced with a separate ALTER TABLE Script to Assign a Key to a Table, such as:
      ALTER TABLE [Table_Name]
      ADD CONSTRAINT ID_PK PRIMARY KEY (Primary_Key)
    • If there are any CREATE NONCLUSTERED INDEX statements in the script, these will need to be modified. For example remove the bold type text from the below script section:
      CREATE NONCLUSTERED INDEX [IX_UserTable_FirstName] ON [dbo].[UserTable]
      (
      [FirstName] ASC
      )WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF,ONLINE = OFF) ON [PRIMARY]
      GO
That’s it, now run the script against the SQL Azure database (ie click New Query in SSMS, select the target SQL Azure database from the dropdown database listing  and clickExecute).
It should be noted that this is as of SQL Azure Update 1 (February 2010) , SQL Azure is currently developing rapidly and not all the inconsistencies with SQL Server are well documented.

How to Migrate an ASP.NET application to Windows Azure


Migrating existing ASP.NET sites to Azure is a process that right now must be performed manually (no sign yet of a migration tool).  The Azure Web Role is very similar to an ASP.NETweb project but has some significant differences which unfortunately mean that a straight copy of the project won’t do the trick.
It is possible to add as Cloud Service project to a solution with an ASP.NET web site but the simplest solution is to create a solution with a Cloud Service and a Web Role and copy the files over, and so I will follow this procedure for this walk-through:
  1. Create a Cloud Service and a Web Role in Visual Studio. Please refer to this this tutorialfor details on doing this. So your solution should look like below:
    ScreenHunter 01 Feb. 23 15.34 Migrating an ASP.NET site to an Azure Web Role
  2. Open the folder of the ASP.NET website to be migrated in the File Explorer and drag the files across to the Web Role (you can just open the standard  Windows File Explorer and place it next to Visual Studio). Do not copy the bin folder and the web.config file.
  3. Manually add the references of the ASP.NET website to the Web Role (Right-click the Web Role in the Solution Explorer and select Add Reference…).
  4. All the .aspx pages in an Azure Web Role have an associated designer.cs or designer.vb page in addition to the code behind page. To manually generate to these files, select the .aspx pages, right-click and select Convert to Web Application.
    ScreenHunter 02 Feb. 23 15.38 Migrating an ASP.NET site to an Azure Web Role
  5. In an ASP.NET web application files in the App_Code folder usually have their build action set to Content. In an Azure Web Role these files need to be set to Compile. To do this, select the files in the App_Code folder, right-click and select Properties. In the Properties window set the Build Action to Compile.
  6. Copy the configuration elements from the web.config  in your ASP.NET site to the web.config in the Azure Web Role. This can be quite tedious but the quick fixes to this often create compilation errors or overwrite some key features of Azure (such as Diagnostics).

SQL Azure Backup Using Database Copy


Backup is currently a major gap in the SQL Azure product, but with support for Database Copy TSQL command has given at least one option for directly backing up a SQL Azure database by copying a source Azure database to a newly created  Azure database.
The TSQL command structure below provides will produce a copy of a database:
CREATE DATABASE  database_destination_name
AS COPY OF [source_server_name.]database_source_name

Note that this TSQL syntax allows for copying to a different Azure server. This is not necessary to protect the data from a disaster recovery point of view since the data is replicated across 3 geographic locations, but it might be required if you wish to copy the database to a different admin account or perhaps a different Azure account that would be billed separately to the source database account. If the database is copied to a new server the exact same login/password pair executing the command must exist on both the source server and destination server.
The copying process will not result in any downtime for the source database, and the copy will be a full copy complete with transactional data (note that this will be the transaction data as at the end time of the copying process not the start time of the copying process).
To monitor the copying process and determine if there were any copying errors you can query the sys.dm_database_copies view. The below command will retrieve all the data regarding the copying process:
Select * from sys.dm_database_copies
A major drawback to using Database Copy for backup is cost – each copy/backup will be charged as a new SQL Azure database.