Created
November 2, 2010 14:33
-
-
Save karmi/659689 to your computer and use it in GitHub Desktop.
Install Varnish HTTP cache on a Mac OS X box with Sprinkle and configure it for accelerating CouchDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DS_Store | |
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
gem 'sprinkle' | |
gem 'activesupport', '2.3.5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Varnish HTTP cache on a Mac OS X box with Sprinkle and configure it for accelerating CouchDB | |
# | |
# == USAGE | |
# | |
# $ gem install bundler | |
# $ bundle install | |
# | |
# $ sudo bundle exec sprinkle --verbose --script=varnish-couchdb-accelerator.rb | |
# | |
# == INFORMATION | |
# | |
# Assuming you have Couch running on port 5984 and such, swap: | |
# | |
# http://localhost:5984/my-database/_design/app/_view/by_something | |
# to: | |
# http://localhost:8080/my-database/_design/app/_view/by_something | |
# | |
# and you should notice some speed difference (eg. in Firebug). | |
# | |
# Then stress load the stack with: | |
# $ ab -c 50 -n 1000 "http://0.0.0.0:5984/..." | |
# and: | |
# $ ab -c 50 -n 1000 "http://0.0.0.0:8080/..." | |
# | |
# You should see what this is all about. | |
package :varnish do | |
requires :varnish_dependencies | |
description 'Varnish HTTP Cache' | |
version '2.1.4' | |
source "http://www.varnish-software.com/sites/default/files/varnish-#{version}.tar.gz" do | |
pre( :configure ) { 'sh autogen.sh' } | |
end | |
verify do | |
has_executable 'varnishd' | |
has_file '/usr/local/etc/varnish/default.vcl' | |
end | |
optional :varnish_couchdb_configuration | |
end | |
package :varnish_mac_dependencies, :provides => :varnish_dependencies do | |
noop { pre :install, 'ln -sf /bin/bash /bin/sh' } | |
mac_port 'automake autoconf libtool libxslt ncurses pcre groff' | |
end | |
package :varnish_linux_dependencies, :provides => :varnish_dependencies do | |
noop { pre :install, 'ln -sf /bin/bash /bin/sh' } | |
apt 'automake autoconf libtool libxslt ncurses pcre groff' | |
end | |
package :varnish_couchdb_configuration do | |
configuration_file = '/usr/local/etc/varnish/default.vcl' | |
push_text <<-'CONFIG', configuration_file, :sudo => true | |
# Varnish Configuration for CouchDB | |
backend default { | |
.host = "127.0.0.1"; | |
.port = "5984"; | |
} | |
CONFIG | |
noop { post :install, 'varnishd -f /usr/local/etc/varnish/default.vcl -s malloc,256MB -T 127.0.0.1:2000 -a 0.0.0.0:8080' } | |
verify { file_contains configuration_file, '5984' } | |
end | |
policy :varnish_couchdb_accelerator, :roles => :app do | |
requires :varnish | |
end | |
deployment do | |
delivery :local | |
source do | |
prefix '/usr/local' # where all source packages will be configured to install | |
archives '/usr/local/sources' # where all source packages will be downloaded to | |
builds '/usr/local/build' # where all source packages will be built | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment