Compressed UTF-8 Strings in SQL Azure

August 31, 2011  |  , ,  |  No Comments  |  Share

Quick Summary
Save money by compressing strings in SQL Azure using UTF-8, deflate and the DotNetZip libary.
SQL Azure costs are primarily based on which size database you choose to provision. Given the premium over the cost of blob storage you’ll want to avoid storing large amounts of data that could be kept in files. However, most applications have several medium sized text fields which aren’t used as query modifiers. It might be something like user comments to a blog post or in my case, product descriptions on a shopping site. These fields are ideal candidates for compression to reduce costs. The enterprise edition of SQL Server has both row and page level compression, but unfortunately this feature hasn’t made it to SQL Azure yet.

Wayne Berry has a great post which discusses which columns are good candidates for manual compression and walks through the process of converting a column to use .NET GZipStream compression. In this post, we’ll build on that approach by using UTF-8 encoding, deflate, and the DotNetZip library to improve our compression ratio.

Read More Post a comment (0)

Performance of jQuery UI and Public CDNs

July 2, 2011  |  ,  |  No Comments  |  Share

Quick Summary
Pay attention to the evaluation cost of scripts. If you are only using a small piece of jQuery UI, then it may be better to host a custom version rather than using the full version on Google’s CDN.

Google, Microsoft, and Yahoo all have content delivery networks (CDNs) to provide common JavaScript libraries for public use. This is a great service which helps to speed up the web by allowing many different sites to link to the same JavaScript library, increasing the chance a user will have a file in their cache. If you are currently hosting your own copy of a library like jQuery, switching to the Google CDN is usually an easy way to improve the speed of your site.

Read More Post a comment (0)

Years and Months Between Dates

June 22, 2011  |   |  No Comments  |  Share
Quick Summary
Calculating the number of years and months between two dates can be tricky. DateSpan to the rescue!

At first glance, calculating the difference between two DateTimes seems easy. Simply subtract the first date from the second and you’ll get a TimeSpan which can be used to get the total number of days elapsed. With the 4th of July right around the corner, let’s calculate the age of the United States since the Declaration of Independence:

Read More Post a comment (0)

Changing IIS Logging Fields in Windows Azure

June 6, 2011  |  ,  |  7 Comments  |  Share
Quick Summary
IIS Logging in Windows Azure includes everything. Reduce the fields logged using appcmd inside a startup task.

Windows Azure makes it pretty easy to enable IIS logging for your web roles and will periodically transfer logs to a storage account so you can analyze them. A typical IIS installation will include some essential fields and administrators can add others if needed. However, Windows Azure enables all of the fields by default.

Read More Post a comment (7)

Serving GZip Compressed Content from the Azure CDN

April 8, 2011  |  ,  |  9 Comments  |  Share


Quick Summary
CDNs like Windows Azure and Amazon CloudFront don’t automatically gzip. Create gzip copies of your css and js to increase site speed and reduce transfer costs.

There are two big reasons why you should compress your content: time & money. Less data transferred over the wire means your site will be faster for users and bandwidth costs will be lower for you. Compressing the content will require some CPU, but web servers are often IO-bound and have cycles to spare. Plus, modern web servers do a good job of caching compressed content so even this cost is minimal. It’s almost always worth it to enable compression on your web server.

Read More Post a comment (9)

Throttling Web API Calls

April 1, 2011  |  ,  |  10 Comments  |  Share
Sign outside Wallington, England (CC-BY by anemoneprojectors)
Quick Summary
Many APIs limit the number of calls per second. TimeSpanSemaphore can help throttle pending calls so that you do not exceed the service limits.

From Amazon to Zillow, there are thousands of sites which provide access to data via an API. At FilterPlay we use lots of e-commerce APIs to retrieve product data and update prices used in our comparison engine. Our back-end system updates millions of items every day and fortunately many of these API calls and updates can be parallelized. Most APIs provide limits to help ensure the service remains available and responsive. It’s important to throttle your API calls to stay within the limits defined by each service.

Read More Post a comment (10)