fromMarch 2013
Column:

Caffeinated Drupal

Introduction to CDNs
0

A high-performance website is like a great cup of coffee: Both are heavenly when conditions are optimal, but there are small things that can quickly turn them from an enjoyable experience into something that leaves a very bitter aftertaste. With the right tools and preparation, it's possible to create a website (or cup of joe) that can be dependable (like that first sip of coffee in the morning), fast to respond (like a quick shot of espresso), and scalable for many visitors (like that fancy cappuccino machine at Williams Sonoma, the one you casually mention to all your friends as your birthday approaches).

This is the first in a series of columns on the subject of “Caffeinated Drupal,” where I'll cover Drupal performance issues, always being sure to relate the topic to my favorite beverage.

Let's get started, shall we? Grab a steaming cup of java (or iced, if you prefer) and we’ll set out to learn about Content Delivery Networks (CDNs) and how they can give a huge speed boost to your website, with minimal configuration. Not sure which coffee to choose today? I recommend a lovely Ethiopian Sidamo served as a cappuccino — nothing like that powerful fruit flavor with undertones of bittersweet chocolate — topped with a dab of perfectly-foamed milk.

For those of you who aren't familiar with the concept of a CDN, picture it as a bunch of geographically dispersed web nodes which act as a front-end to your website. By bringing content physically closer to the end user, the improved speed of your load times can be staggering. You can also deal with traffic spikes much easier and without having to massively scale up your infrastructure — saving you money both on hardware and bandwidth.

There are many CDN providers, some much larger than others in terms of servers, geographic locations, and network presence. There are also various types of CDN plans, the most common being either a flat rate for a set amount of traffic, or a pay-as-you-go fee based on how much traffic you transfer. Typically, the larger the CDN network, the more expensive it will be. The benefit of using a larger CDN network is it will have end points in close physical proximity to more of your visitors, thereby serving your content to visitors faster than if they had to traverse multiple network links. You can think of the larger CDN companies a lot like Starbucks in the coffee world — you can never go too far without coming across a Starbucks (or two or three).

Once you've purchased a plan on a CDN, the next step is to integrate it with your website. There are two main methods used by CDNs for getting your content onto the CDN servers: origin push and origin pull (“origin,” in this case, means your web server). With the push method, you are responsible for manually or programmatically uploading your content to the CDN. The pull method is just the opposite; the CDN will automatically request content from your server when it receives a request and doesn't have that content already cached. The pull method is generally much easier to set up, since it doesn't take any configuration on your end outside of changing your URLs to point to the CDN. So how can we set up Drupal to interact with a CDN? It's easy with the Drupal CDN module.

Once you install the CDN module, you will be able to configure settings which tell the module which URLs to re-write your content to. For example, you'll likely set up domains such as cdn1.example.com and cdn2.example.com and point those to the CDN servers (this will be described in the setup documentation for your CDN provider). The CDN module will then automatically re-write URLs using your CDN hostname(s) for you so that instead of serving static content from your web server, it will be pulled from the CDN instead. For example, an image tag which references http://example.com/sites/default/files/test.png will be automatically re-written so that it uses http://cdn1.example.com/sites/default/files/test.png, which serves the image to your visitors from the CDN.

Wow, that was easier than ordering a double soy no-foam latte at your neighborhood coffee shop!

Advertisement

From our blog

Entity Storage, the Drupal 8 Way

In Drupal 7 the Field API introduced the concept of swappable field storage.

The Drupal 6 to 8 Upgrade Challenge - Part 2

Having concluded the readiness assessment, we turn next to migrating the content and configuration. In reality, there’s little chance that we would migrate anything but the blogs from our old site. For the sake of giving Migrate in Core a workout with real conditions, however, we’re going to upgrade with core’s Migrate Drupal module rather than rebuilding.

The Drupal 6 to 8 Upgrade Challenge - Part 1

Nathaniel Catchpole , the Drupal 8 release maintainer and Tag1 Senior Performance Engineer, suggested that Drupal shops everywhere could support the

DrupalCon Austin

The entertainment industry is not for the faint of heart.

Drupal Watchdog Joins the Linux New Media Family
Drupal Watchdog 6.01 is the first issue published by Linux New Media.

Drupal Watchdog 6.01 is the first issue published by Linux New Media. Come see the Drupal Watchdog team at DrupalCon 2016!

Drupal Watchdog was founded in 2011 by Tag1 Consulting as a resource for the Drupal community to share news and information. Now in its sixth year, Drupal Watchdog is ready to expand to meet the needs of this growing community.

Drupal Watchdog will now be published by Linux New Media, aptly described as the Pulse of Open Source.

Welcome to DrupalCon Barcelona - The Director's Cut

For all you schedule-challenged CEOs – and ADHD coders – this Abbreviated Official Director’s Cut is just what the doctor ordered.

Welcome to DrupalCon - The Barcelona Edition

Did we have fun in Barcelona?
OMG, yes!

Did we eat all the tapas on the menu and wash them down with pitchers of sangria?
Yes indeed!

Recursive Closures and How to Get Rid of Them

This came up while manipulating taxonomy children and their children recursively, so it’s as not far from Drupal as you’d think.