On one of my current projects called diginights.com we are heavily using the popular and free Ad server solution OpenX for banner delivery. To optimize its performance and spread the http connections over multiple domains to boost the page speed we decided to outsource the ad images to a Content Delivery Network (CDN). We chose the Amazon Web Services for a first test due to the easy installation and configuration of their cloud services.
The two services to enable in your Amazon Web Management Console are Amazon S3 (storage solution) and CloudFront (CDN distribution). We sync the images between our root servers and Amazon S3 with the help of the fuse integrated and free filesystem s3fs (FuseOverAmazon).
First of all you need to get an Amazon S3 account on http://aws.amazon.com/s3/ and set up a new S3 Bucket (beware that every bucket name needs to be unique) in a region that fits your needs, create a CloudFront Distribution for the Bucket and wait until its enabled. The images below should be enough to help you with setting up AWS:
- Creating an Amazon S3 Bucket
- Create Amazon Cloudfront Distribution
- Deployment of Amazon Cloudfront
Please note the *.cloudfront.net. You’ll need it later for OpenX configuration. You could also set up a CNAME in your DNS system, configure this CNAME in the CloudFront Console and deliver the ad images via this CNAME from OpenX.
Installation of s3fs on our Debian Linux servers is fairly easy:
- Grab the recent version of s3fs from its download page and extract it somewhere (eg. /usr/src)
- Install installation prequisites via
apt-get install build-essential libfuse-dev fuse-utils libcurl4-openssl-dev libxml2-dev mime-support
- Compile and install s3fs
- cd s3fs-1.16/
- ./configure –prefix=/usr
- make
- make install (as root)
- Put your security credentials either in /root/.passwd-s3fs or the system-wide file /etc/passwd-s3fs. Please take care of the file permissions. The syntax in the file is simple accessKeyId:secretAccessKey ( or bucketName:accessKeyId:secretAccessKey for multiple buckets)
- Enable fuse module, if it isn’t already in use:
modprobe fuse
- You should then be able to mount your bucket to your local filesystem:
s3fs bucketName mountpoint
- Put a similar entry in the fstab of your servers:
s3fs#bucketName /space/amazons3 fuse default_acl=public-read,allow_other 0 0
public-read is necessary to make sure that copied files are available online for every user.
- That’s it for the s3fs part. Now you have to reconfigure your OpenX Installation
- Change the Local Directory under Global Settings -> Banner Storage Settings to the directory where your S3 mountpoint is located.
- Change the Image Store URL for HTTP & HTTPS under Global Settings -> Banner Delivery Settings to your *.cloudfront.net Domain (Or your own CNAME URL).
- Save the settings, sit back and relax! But don’t forget to check your AWS account balance



[...] This post was mentioned on Twitter by Norbert Doetsch, Andreas Lehr. Andreas Lehr said: New Blog entry: OpenX Perfomance optimization with Amazon S3 and CloudFront as CDN http://bit.ly/gUItZV #amazon #aws #openx [...]
Thanks for the howto.
Just a couple of notes:
-On Ubuntu 10.04 and later one is not required to run modprobe fuse. The module is already loaded into the default kernel
-The system wide file name to store access credentials shall be /etc/passwd-s3fs (not /etc/passwd-s3)
Unless I am missing something, after changing the image storage URL’s, the existings banners no longer display.
did you copy the banners into the new directory? (this will take a wile, depending on the amount of images)