Off-loading wpmu theme files to Amazon-S3
I saw a few people looking for solutions to off-load wpmu files to Amazon-S3 service. This is something we wanted to try on our installation (just a few thousand blogs) so I wrote a plugin that will serve themes css and image files from S3.
The plugin uses the ‘stylesheet_directory_uri‘ filter to set the stylesheet uri (css file). In turn, the stylesheet uses the ‘url‘ method to call the image files of the theme so they get the same base url as the stylesheet. Most themes uses the ‘stylesheet_directory‘ call correctly so you will not run into trouble but if a theme uses it to call a php file you should change the call to use ‘template_directory‘.
Download: themes-s3.zip
Usage:
- Signup for an Amazon-S3 account.
- Create a bucket for your files. Since you have to select a globally unique name for your buckets I call it s3.domain.com were domain.com is my wpmu installation.
- To point s3 to your bucket setup a CNAME record: s3 -> s3.domain.com.s3.amazonaws.com. (don’t forget that extra dot at the end).
- Load your themes css and image files to your bucket keeping the exact directory structure for each theme (/wp-contents/themes/… ). You can use the excellent S3 FireFox Organizer to mange your files.
- Edit the plugin to include your bucket name.
- Place the plugin in the mu-plugins directory.
- Test, test and test all your themes!
Whats next? The next step I’m planning is to off-load the Java Scripts in the wp-includes folder. Also planned is an option to serve the users files from S3. If you are interested in helping in any way please leave a comment and we can take it from there.
Did you find this post interesting? Please subscribe to my feed.
I would not say speedboost but this is one of the measures we take to reduce the stress on the server (caching would be anther one).
btw, your home page is great, did you share your nice mootools effects ?)
Thanks for the kind words. I haven’t shared my homepage, at least not in a nice downloadable form, primarily because it’s not pretty code. You can of course download all of the necessary scripts to make those funky animations from the mootools homepage.
With respect to speedboosts, I’ve been working hard on optimizing my site load times over the past couple of weeks, including setting up APC, wp-super-cache, and boosting mysql cache. My next step is to try and figure out how to get gzip encoding to work. Have you had any luck with that?
For caching we use super-cache. I did made a hack so the cache will be cleared when a user updates his widgets.
Why would go want to gzip? This may save you bandwidth but that is not an issue, or is it?
I set up an s3 bucket an cnamed a subdomain there like assets.yourdomain.com.
Then I did a find and replace in script-loader.php and placed the subdomain before every .js file.
It’s a pretty sucky way of doing it. But it only took me a minute to change the file with find and replace.
With Nginx you can actually set it up to proxy any requests to /wp-includes/js/ to an s3 bucket. That way it appears as though your javascript is coming from http://yourdomain.com/wp-includes/js/script.js when really its being served by an s3 bucket.
How did you do it? Is it with the super-cache plugin settings?
[...] Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs [...]
[...] Ring Of Blogs blogging, wordpress-MU, monetization and stuff… « Off-loading wpmu theme files to Amazon-S3 [...]
That is where most of my storage is … freakin user’s uploading massive pictures.
http://tantannoodles.com/toolkit/wordpress-s3/
[...] Off-loading wpmu theme files to Amazon-S3. [...]
I had a closer look at the plugin I mentioned, and found a sample configuration file. It seems you can pre configure the values to be used for wpmu there and that should make it run as a wpmu plugin as opposed to its normal usage under wp.
Maybe after Christmas. I do have a couple of clients asking about this. Our servers don’t have that much load though and we’re moving all of our mu installs onto their own boxes anyway.
The pixel audio plugin got a fix to use amazon as well.
And video for streaming.
Can this be done?
Sean
[...] your themes to Amazon S3 to distribute server load (like wordpress.com) – Utilise a WordPress MU plugin to unload our Themes to Amazon [...]
[...] Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs. tags: amazon, aws, s3 storage, wordpress, wordpress mu older » BRRR..Snow in Montpelier » No Responses to "Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs". Add a comment? or Follow comments by RSS? Be the first and share your thoughts! [...]
[...] Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs (tags: wordpress) [...]