Archive for December, 2010

30 Dec 2010

Layouts And Sections With Razor

No Comments Uncategorized

Yesterday night I had decided, that this morning I was going to sit down and write a post on the uses of the IsSectionDefined method in the Razor syntax, and how useful it was for determining if views were implementing certain sections in a layout.  (which is very useful and provides a great deal of flexibility in your design)

image

However this morning I awoke to find that Scott Guthrie had written about the same subject, and who am I to compete against The Gu.

http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx

Enjoy!

22 Dec 2010

Setting up a CloudFront Mirroring CDN in 5 minutes

6 Comments Uncategorized

Recently I decided it was important to get away from Google App Engine as my CDN, mostly because I have encountered personally and have been told that many internal corporate networks are blocking Google App Engine IP’s.  And since most of my content posted to this blog is relevant to developers, who typically work in the corporate world, I decided to make the move.  And boy am I glad I did.

If you already know the purpose of a CDN please skip ahead.

What is a CDN?

According to Wikipedia on what a CDN is:

A content delivery network or content distribution network (CDN) is a system of computers containing copies of data, placed at various points in a network so as to maximize bandwidth for access to the data from clients throughout the network. A client accesses a copy of the data near to the client, as opposed to all clients accessing the same central server, so as to avoid bottlenecks near that server.

Straight forward enough right?  Basically servers specifically designed for delivering static content as fast as possible to the client’s browser so that web pages spend less time loading.

So what is a mirroring CDN?

A mirroring CDN doesn’t require you to upload anything to get started.  Basically you point it at your server where all the content is located.  As requests are made to the CDN for your static content, it retrieves it from your servers and stores it on the CDN network for a specific amount of time before it looks for a fresh copy.  While stored on the CDN network it constantly serves from that cached copy, this reduces the bandwidth and strain on your server, because the CDN only requests the static file once until the CDN file has timed out.  The time out is typically an hour or a day, but can be longer based on your settings.

Setting up a mirrored CDN

The first thing you will want to do is setup an Amazon Web Services account, which can be done, for free, here:

http://aws.amazon.com/

After you have a confirmed account, you can start your stop watch for the 5 minutes, if you are really timing me.

  1. Sign in to the console: https://console.aws.amazon.com/s3/home
  2. Click the Amazon CloudFront tab, and you will see a screen that looks like this:
    empty-aws-console
  3. Click the Create Distribution button, and this screen will appear:
    create-aws-cloudfront
  4. Select Other… from the Origin drop down.
  5. In the Bucket Name enter the domain that you want to mirror, in my case it is coderjournal.com.
  6. If you want to use a CNAME for your mirroring CDN, which is totally optional, enter it in the CNAMEs textbox, in my case it is cj.mf.io.
  7. Make sure Distribution Status is set to Enabled.
  8. After all fields are filled in it will look something like this:
    filled-in-aws-cloudfront
  9. Click the Create button, and you are done.
  10. When the State says Deployed you are ready to start serving your content from you new mirroring CDN.
    filled-aws-cloudfront
  11. If you decided to use a CNAME for the CDN, just take the Domain Name field on the left hand column and enter that for the CNAME in your DNS.

Stop your stopwatches, we are done.

How do I use it?

Well this is the great part, and probably the easiest step.  Where ever the static files reside on your domain that you entered in as the Bucket Name just use that same path but replace the domain name.

For example, I host a picture of my book on coderjournal.com which can be accessed using the following URL:

If I want to access this same resource from my mirroring CDN, I just swap out the “coderjournal.com” for “cj.mf.io” and the mirrored copy is available from 17 locations around the world.  (as of writing this blog post)

To incorporate this in to your web applications just start using the new mirrored CDN domain for you static content instead of your web applications domain.

What will this cost me?

Obviously applications and usages differ but as an example of how dirt cheap this service is in my opinion.  Here is the break down for the whopping $1.22 that I have racked up this month so far:

cloud-front-bill

Conclusion

Hopefully this is going to help you take the plunge because you can get a ton of extra bandwidth from your applications server by deploying the static content to a CDN.  And between the low cost and easy setup of the CloudFront service, it is really a no-brainer.

Have a Merry Christmas and a Happy New Year.

12 Dec 2010

Enabling Pinging in Windows 2008 R2

No Comments Uncategorized

For the life of me I couldn’t find an easy option to enable pinging, an ICMP Type 8 or Echo Request response, through my Windows 2008 R2 firewall. 

Every hit on Google told me to follow some steps through the GUI that ended up not being in R2 anymore or execute the following command which doesn’t seem to work in R2 either. 

netsh firewall set icmpsetting 8 enable

netsh would always respond back and tell me that firewall was depreciated, but not give me much more to go on. 

So I am writing this post for selfish reasons of having an easy place to look up the solution when I need it, also to help anybody else who may need help.  To enable pinging in Windows 2008 R2 you need to execute the following advfirewall firewall command on netsh.

netsh advfirewall firewall add rule name=”ICMP Allow incoming V4 echo request” protocol=icmpv4:8,any dir=in action=allow

After you execute this command you will receive a response simply stating Ok

In my opinion this command seems to be a step backwards in simplicity, however this feature isn’t really meant for your every-day user.  But I just wanted to share incase anybody else was caught in the same Google searching hell that I was.