Skip to content

Gallery and the Coral Distribution Network

The Coral Distribution Network (CDN) is a very nice shiny toy for all of us who sometimes struggle with limited bandwidth. Let the NSF pay for it!

My photo album is what chews up the most bandwidth from my site, so it made sense to rig it up first to optionally be available via CDN. CDN is basically just a big Akamai-like network of servers that cache things and serve them up to you from servers that are close to you network-wise. It is has some fancy code behind it, but who cares how it works, it just does. Let's get to the interesting part. As you have probably figured out by now, you can access any site on the Web via Coral by simply appending ".nyud.net:8090" to the domain part of the URL and there are plugins available that add a menu item to automatically do this for you client-side. The problem with this is that you don't want to have to do this for every page on a site. It would be much nicer if the site would adjust its links such that if you enter the site via Coral, all the local links from that site would be Coral links. You may of course want to make some exceptions for pages that are interactive in some way, but for something like a photo album where 99% of people just look at mostly static content it works well.

You can see the patch at http://gallery.menalto.com

Note again that this quick hack does not in any way handle links that shouldn't be Coral'ed. Like the login link, comment stuff or all the administrative tools. It turns your Gallery into a read-only site if you come in using Coral. As the administrator of my album I can figure out that I need to go directly to it in order to add photos. But a more complete patch that doesn't Coralize stuff that shouldn't be would be nice.

You can have a look at it in action at http://www.phpics.com.nyud.net:8090/

I submitted it to the Gallery Folks so let's see if they take it and run with it to integrate it completely.

Update: A variation of this that also supports people running their Gallery on weird ports has been committed to Gallery's CVS, so you may just want to update from there to get it.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

G on :

Wow, coolness. Had never heard of Coral.

PS - Rasmus - update your toys page more often - it rocks!

Andreas Koepke on :

Wow, this is really cool. I have never heard of Coral at all before, this rocks.

The only thing that sucks a bit is that Google ads don't automatically load when the link is accessed via their system.

I think I will certainly begin using this system to reduce some of my bandwidth costs

plumsauce on :

The link through coral does not appear to be working at the time this comment was posted. Tried it twice just to be sure.

Girish Kalele on :

You don't need any code...all you have to do is use the MirrorURL feature already present in Gallery.
Point the mirror URL to the coral url of your albums directory...Gallery will try to check the lock/dat file there, find that it is identical to it's local copy, decide that it is a valid mirror and point the IMG tags to the Coral Web Cache URL.
Done !
No problems with any links/cookies/etc not working.
And anyway, you will keep serving the HTML pages from your server, and the bandwidth-hogging photos from the Coral Cache (I've observed that the CDN cache is getting thrashed so much that things fall out of the LRU cache pretty quickly nowadays).
Try it out, you'll eliminate all your cookie/link problems...moreover, your click counters will be accurate.

Rasmus on :

Right, but I only want stuff to come from CDN if the user chose to use CDN by accessing my data via CDN. I don't see how to do that via the MirrorURL feature.

joe mawm on :

Right on rasmus! Welcome back. I was beginning to think that maybe you died.

Jeremy Brand on :

I went a level lower:

ServerName www.nirvani.net
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/misc/.+ [NC]
RewriteCond %{HTTP_USER_AGENT} !CoralWebPrx [NC]
RewriteCond %{HTTP_USER_AGENT} !GoogleBot [NC]
RewriteRule . http:\/\/www\.nirvani\.net\.nyud\.net:8090%{REQUEST_URI} [R]

Jeremy

Jeremy Brand on :

Let's try that with some formatting:


ServerName www.nirvani.net
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/misc/.+ [NC]
RewriteCond %{HTTP_USER_AGENT} !CoralWebPrx [NC]
RewriteCond %{HTTP_USER_AGENT} !GoogleBot [NC]
RewriteRule . http:\/\/www\.nirvani\.net\.nyud\.net:8090%{REQUEST_URI} [R]


Jeremy

lenbuster on :

Very neat!

Content Distribution Networks are way interesting, aren't they? It's a little annoying, however, that Coral runs off a non-standard port and makes use behind restrictive firewalls and/or proxies somewhat limited. Oh well.

The author does not allow comments to this entry

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
Form options

Submitted comments will be subject to moderation before being displayed.