Bulb Flash:- Few tips to Reduce Cost and Optimize performance in Azure!

Applications deployed on azure are meant to 1. Perform better at 2. Lesser cost.

As a software developer its inherently your job to ensure this holds true..

Here are a few pointers to keep in mind when deploying applications on Azure to make sure your clients are happy:-)

Application Optimizations

  • Cloud is stateless , so if migrating an existing ASP.NET site and you are expecting to have multiple web roles up there then you  cannot use the default in memory Session state..You basically have 2 options now
    • Use ViewState instead . Using ASP.NET view state is an excellent solution so long as the amount of data involved is small. But if the data is huge you are increasing your data traffic , not only affecting the performance but also accruing cost… remember..inword traffic is $.10/GB and outgoing $0.15/GB.
    • Second option is to persist the state to server side storage that is accessible from multiple web role instances. In Windows Azure, the server side storage could be either SQL Azure, or table and blob storage. SQL Azure storage is relatively expensive as compared to table and blob storage. An optimum solution uses  the session state  sample provider that you can download from http://code.msdn.microsoft.com/windowsazuresamples. The only change required for the application to use a different session state provider is in the Web.config file.
    • Remove expired sessions from storage to reduce your costs. You could add a task to one of your worker roles to do this .
  • Don’t go overboard creating multiple worker roles which do small tasks. Remember you pay for each role deployed so try to utilize each node’s compute power to its maximum. You may even decide to go for a bigger node instead of creating a new worker role and have the same role do multiple tasks.

Storage Optimization

  • Choosing the right Partition and Row key for your tables is crucial.Any process which needs to tablescan across all your partitions will be show. basically if you are not being able to use your partition key in the “Where” part of your LINQ queries then you went wrong somewhere..

Configuration Changes

  • See if you can make the following system.configuration changes..
    • expect100Continue:- The first change switches off the ‘Expect 100-continue’ feature. If this feature is enabled, when the application sends a PUT or POST request, it can delay sending the payload by sending an ‘Expect 100-continue’ header. When the server receives this message, it uses the available information in the header to check whether it could make the call, and if it can, it sends back a status code 100 to the client. The client then sends the remainder of the payload. This means that the client can check for many common errors without sending the payload. If you have tested the client well enough to ensure that it is not sending any bad requests, you can turn off the ‘Expect 100-continue’ feature and reduce the number of round-trips to the server. This is especially useful when the client sends many messages with small payloads, for example, when the client is using the table or queue service.
    • maxconnection:-The second configuration change increases the maximum number of connections that the web server will maintain from its default value of 2. If this value is set too low, the problem manifests itself through "Underlying connection was closed" messages.

WCF Data Optimizations(When using Azure Storage)

  • If you are not making any changes to the entities that WCF Data Services retrieve set the MergeOption to “NoTracking”
  • Implement paging. Use the ContinuationToken and the ResultSegment class to implement paging and reduce in/out traffic.

These are just a few of the aspects we at Cennest keep in mind which deciding the best deployment model for a project..

Thanks

Cennest!

Azure:- What Azure Offers and what exactly does “Compute” mean?

An architect always has the tough job of convincing the client that the solution deployed is “optimum” under the given constraints!!.

Especially when it comes to Azure where there is a constant Cost vs Compute fight!!.

Got this excellent diagram from the Windows Architecture Guidance which illustrates what you get when you create an Azure account..

image

Basically when you select Azure as an offering in your subscriptions you get

  • One Azure Project(Portal).
  • Within this portal you can host upto 6 Services(Websites)
  • Upto 5 Azure Storage Accounts(each with 100TB of data).
  • Interesting Limitation:- Each service can have only upto 5 roles(Web+ worker in any combination)
  • Very Interesting Limitation:- The entire project can consume only 20 compute instances!!

The last point is extremely important, but to understand its significance we need to understand some basics in Azure.

You create your service as a combination of web + worker roles, each role you configure runs on a Virtual Machine(VM) 

For each role you can define the size of VM you prefer, based on the memory and disk space requirements expected or that role.

Here are the configurations for the VMs

image

Compute Power is equal to the number of CPU cores being consumed by your VM!!

Suppose you had 2 role configured for 3 instances, each on Large VMs then you consumed 2*3*4=24  instances of the CPU core and are actually out of space!!.

The  calculation is Role*instances*No of CPU Cores in VM.

A very important point to remember when you define the tasks being accomplished by your roles and the kind of VM they are being hosted on!!

Cennest!!