Showing posts with label Network. Show all posts
Showing posts with label Network. Show all posts

Sunday, May 1, 2011

HowTo: Configure Vbulletin To Use A Content Delivery Network (CDN)

The last time I wrote about CDN, I wrote about how to configure CDN for wordpress to speed up your wordpress blog to display content to users faster and more efficiently. However, a few regular readers like to know how to configure the Amazon CDN or other CDN network to use with Vbulletin forum software. In this quick tutorial, I will explains how to configure Vbulletin, Apache/Lighttpd webserver, Bind dns server to use a CDN to distribute your common files such as css, js, user uploaded files and lighten load on your web server.

Forum URL : http://nixcraft.in/ - This is hosted on your own server using Apache, Lighttpd, or Nginx.Origin Pull URL : http://cdn-origin.nixcraft.in/ - This is hosted on your own server. You need to configure your web server, vbulletin and dns server to use this. This is called as "Origin Pull Host" which is a CDN method by which content is pulled from your web server.CDN URL : http://cdn.nixcraft.in/ - This is a cdn url hosted by your CDN provider such as Amazon. This url always point to an edge server via proprietary DNS hacks. cdn.nixcraft.in must be set as CNAME records which will point to domain names of CDN server.CDN DNS CNAME : cdn.nixcraft.in.example.com - example.com is your CDN provider. This is must be set as CNAME for cdn.nixcraft.in

As I said earlier the cost varies between CDN providers. Check CDN service providers website for more information. Next, you need to use service providers "control panel" to configure an "Origin Pull Host" for each domain. In other words configure cdn.nixcraft.in in origin pull mode. The control panel will also provide your an option to setup CDN dns CNAME. You need to use same CNAME in step # 2. Once the configuration is active and the CNAME is resolving, calls to cdn.nixcraft.in will be cached from cdn-origin.nixcraft.in.

I'm assuming that you are using BIND dns server edit your zone file and add entry as follows (you can skip this step and use your ISP's dns hosting providers control panel to setup CNAME and origin host):

; CDN CNAME mapping for cdn.nixcraft.incdn 3660 IN CNAME cdn.nixcraft.in.example.com.; Your cdn-origin url (note nixcraft.in is also hosted on same server IP 123.1.2.3)cdn-origin 3600 IN A 123.1.2.3

Save and close the file. Reload named:
# rndc reload && tail -f /var/log/messages
To keep your configuration simple use the same web server for origin pull domain and main domain i.e. host both cdn-origin.nixcraft.in and nixcraft.in on same web server. This allows you to directly upload and map files to the CDN server.

You need to configure cdn-origin.nixcraft.in as follows:

Origin pull DocumentRoot: /home/httpd/cdn-origin.nixcraft.in - All your .css, .js and uploaded files are hosted here.Server Forum DocumentRoot: /home/httpd/nixcraft.in - All your vbulletin files are hosted here.MaxAge: Set cache-lifetime headers for static files for cdn network.Etags: An ETag (entity tag) is part of HTTP, the protocol for the World Wide Web. It is a response header that may be returned by an HTTP/1.1 compliant web server and is used to determine change in content at a given URL. When a new HTTP response contains the same ETag as an older HTTP response, the client can conclude that the content is the same without further downloading.ServerAdmin webmaster@nixcraft.inDocumentRoot /home/httpd/cdn-origin.nixcraft.inServerName files.nixcraft.inServerAlias file.nixcraft.inErrorLog /var/logs/httpd/cdn-error_logCustomLog /var/logs/httpd/cdn-access_log common # Files in this directory will be cached for 1 week only.# After 1 week, CDN server will check if the contents has been modified or not.# If not modified, Apache will send 304 "Not Modified" headerHeader set Cache-Control "max-age=604800, must-revalidate" # Disable ETag as we are on cluster Apache serverHeader unset ETagFileETag None # Do not cacheHeader Set Cache-Control "max-age=0, no-store"# Configure ETagsetag.use-inode = "enable"etag.use-mtime = "enable"etag.use-size = "enable"static-file.etags = "enable" ###### CDN FILES via WordPress Upload ##############$HTTP["host"] == "cdn-origin.nixcraft.in"{ server.document-root = "/home/httpd/cdn-origin.nixcraft.in" accesslog.filename = "/var/log/lighttpd/cdn.access.log"# Set max age $HTTP["url"] =~ "^/" { expire.url = ( "" => "access 60 days" ) }}

Adjust documentroot as per your setup.

You need to configure files for cdn-origin.nixcraft.in:
# mkdir -p /home/httpd/cdn-origin.nixcraft.in
# cd /home/httpd/cdn-origin.nixcraft.in
Next, soft link your .css, .js, images, clientscripts files against original forum documentroot (i.e. /home/httpd/nixcraft.in/) as follows:
# ln -s ../nixcraft.in/clear.gif .
# ln -s ../nixcraft.in/clientscript/ .
# ln -s ../nixcraft.in/customavatars/ .
# ln -s ../nixcraft.in/customprofilepics/ .
# ln -s ../nixcraft.in/images/ .
# ln -s ../nixcraft.in/signaturepics/ .
Again, feel free to adjust paths according to your setup. Test your new cdn urls:
http://cdn.nixcraft.in/clientscript/vbulletin_important.css

You need to edit your vbulletin style. Open admincp by visiting http://nixcraft.in/admincp/ > Select Styles & Templates > Replacement Variable Manager:

Fig.01: Vbulletin Editing Styles And Templates Fig.01: Vbulletin Editing Styles And Templates

Click on [Add New Replacement Variable] link and set it as follows:

Set Search for Text to href="clientscriptSet Replace with Text to href="http://cdn.nixcraft.in/clientscript

Sample outputs:

Fig.02: Vbulletin Adding Replacement Variable For CDN Fig.02: Vbulletin Adding Replacement Variable For CDN


You need to repeat this step for images, javascript and other shared media as follows: Search for Text Replace with Textsrc="http://cdn.nixcraft.in/clear.gif"src="http://cdn.nixcraft.in/customavatars/src="http://cdn.nixcraft.in/customprofilepics/src="http://cdn.nixcraft.in/images/url("http://cdn.nixcraft.in/clientscriptsrc="http://cdn.nixcraft.in/clientscript/href="http://cdn.nixcraft.in/clientscript/url(http://cdn.nixcraft.in/images/url(http://cdn.nixcraft.in/images/var imgdir_misc = "images/misc"; var IMGDIR_MISC = "http://cdn.nixcraft.in/images/misc";

Visit Avatars > Storage Type and set them as follows to match your above CDN rules by moving all of them to file systems:

Avatars are currently being served from the filesystem at ./customavatarsProfile pictures are currently being served from the filesystem at ./customprofilepicsSignature pictures are currently being served from the filesystem at ./signaturepics

Use curl to test HTTP headers (look for Etags, max-age and Expires headers):
$ curl -I 'http://cdn.nixcraft.in/clientscript/vbulletin_important.css?v=385'
$ curl -I http://cdn.nixcraft.in/customavatars/avatarx_y.gif

The forum home page loading (rendering) time went from 8.5 seconds to 2.2 seconds and average thread loading time went from 14.3 seconds to 5 seconds:

Fig.03 Speed Improvements With CDN Fig.03 Speed Improvements With CDN


See 6 tools to test web site speed for more information. This blog post is 4 of 4 in the "Networks & Applications of Distributed Computing Tutorial" series. Keep reading the rest of the series:

Friday, October 29, 2010

Asterisk SCF

It’s called Asterisk Scalable Communications Framework, or Asterisk SCF.


It’s a new project from Digium, the Asterisk people, aimed at giving Voice Over IP true integration with other Internet services, on an Internet scale.


They’re quick to note this is not a replacement for the main Asterisk project, now on version 1.8, but is being built on top of it.


The aim is to make SCF a set of distributed components that can be deployed as clusters in a single server and be transparent to the user.


According to the press release, it offers “the full range of real-time IP communications, including video, multi-channel wideband and ultra-wideband audio, chat, desktop sharing and other media types that may arise in the future.”


My late friend Russell Shaw, who covered this beat for ZDNet until his death in 2008, would be proud. Were he still with us I might not be able to finish, we would be so busy Tweeting one another and arguing about things.


Today’s news comes alongside Astricon, Digium’s annual conference and user tribute, going on right now at a resort hotel near Washington, D.C. There users are hearing about stuff like this, Xorcom’s complete hotel solution, an Asterisk PBX that can run the hotel where the conference is being held.


Solutions like this represent where Asterisk has been, and what it has become. VOIP has mainly been developed as a way to get around the phone system, its costs, gatekeepers, and taxes. It is seen by many as a way to cut telephone costs.


But it has always been much more, and with SCF it can become much more. Voice is a low-bandwidth service that can and should be integrated into other Internet services, that can be one ingredient in a larger solution. That process is now well underway.


At which point there will be no more phone network, only ISPs, hopefully in a more competitive market.

Wednesday, October 20, 2010

Social Network Goes Open With Diaspora*

Open source social network Diaspora* has released its source code on github. While the site lacks the level of interactivity as Facebook, it features the barebones features that have come to be expected from social networking sites. Photos and albums can be uploaded, status updates and photos can be publicly and privately shared, and friends can be added and managed.


What separates Diaspora* from Facebook is its security and privacy. All traffic is signed and encrypted with GPG, save photos. The goal of Diaspora* is to decentralize existing networks, allowing users to create their own, personally hosted version of Diaspora* called a seed. A seed connects to other services such as Twitter, Flickr, and yes, Facebook and pulls that information back to the local host. Any information minus photos, sent from your Diaspora* seed is encrypted, as is any incoming information. It's also possible to friend other seeds and its possible to synchronize over direct, secure connections. And because the platform is open source, it's possible to customize your seed's appearance and potentially add new services and support for additional features.

Mozilla Joins The Open Invention Network

The Mozilla Foundation became a licensee member of the Open Invention Network, which specializes in patent defense and Linux preservation. There are three levels of membership to the OIN: Licensee, Associate, and Executive. The Mozilla Foundation has joined as a Licensee.


As a Licensee, Mozilla will have access to the OIN's royalty-free patent library as long as the company doesn't assert said patents against the Linux System.


"By joining, Mozilla receives cross-licenses from other OIN licensees, but more importantly, for the long term, it affords us a chance to work with OIN in reducing IP threats to open source development and innovation," the foundation said via the official Mozilla blog.


Mozilla was quick to say that the foundation is still uneasy about patents, but that based on the good the OIN does in protecting Linux and the network's efforts to shield open source projects from IP threats.