-
Creating a Varnish Load Balancer for Opsworks
Varnish is an amazing platform – it can easily help you handle 100x traffic and is easy to add to your existing frontend or API layer with little to no change to your app.
Here we’ll go over some neat tricks leveraging chef, the AWS Opsworks API and the opsworks
configure
lifecycle event to create a lighting fast load balancer & reverse proxy that automatically updates itself.Setup
-
Create a new
varnish
layer that installs thevarnish
andjq
packages -
Wordpress Cron on Opsworks
By default Wordpress uses it’s own pseudo-cron which triggers with every request. Obviously this is wasteful since (a) the queue needs to be inspected with every GET and (b) jobs like publishing articles will interfere with serving content.
Some suggest calling the
wp-cron.php
GET request with curl in a cron like this* * * * * curl http://www.mysite.com/wp-cron.php
but that’s sub-optimal since it needlessly ties up a worker during the cron execution.
-
Opsworks -- Quickly Listing Hosts on the Command Line
Here’s a great example of using the aws-cli to speed up your life. Uses jq and aws-cli
# bash / zsh function function opsworks-hosts-prod () { aws opsworks describe-instances --stack-id=fffff-fffff-ffff-fff-fffffff | jq '.Instances[].PublicDns' | grep -v null | sed s/\"//g } # usage $ opsworks-hosts-prod XXXXX.compute-1.amazonaws.com XXXXX.compute-1.amazonaws.com XXXXX.compute-1.amazonaws.com XXXXX.compute-1.amazonaws.com
-
Opsworks before-migrate.rb
Opsworks is a convenient, powerful and free service provided by AWS to simplify the management of EC2 nodes. The real power of the system is exposed through customizing various stages of the instance lifecycle by creating custom-tailored chef-solo recipes.
While Amazon provides a powerful deployment layer for PHP applications, it stops short once the PHP code has been checked out of git. For Laravel or other composer apps, you’ll have to customize your deployment. The most elegant and straightforward method is through custom deployment hooks. Here’s how to build a before_migration.rb script to build a Laravel app.
-