Posts Tagged ‘Ruby’

Los Angeles Web Application Developers 10th Meetup Rocked

Monday, August 11th, 2008

We had a great meetup this week on the 5th. There was an attendance of about eighty-five people this time. This meetup also marked the 10th meetup for us. We couldn’t have done it without your eagerness to be part of an evolving tech-community in Los Angeles.

We also have to thank Rubicon for hosting the 10th meetup. They had an amazing looking location, and it even has a bit of Hollywoodesque history associated with it. Apparently, their space was used for the show 24, and we got to see Jack Bauer’s office which is pretty damn cool. We also overheard that Snoop Dogg laid some tracks down in one of the other rooms. Rubicon is definitely one of my favorite web-venues that I’ve seen.

The following was presented at the meetup:

Ari Lerner - Auto-Scaling cloud-computing on amazon EC2 + S3

Nick Merwin - Rolling with Red5 (open source Flash server)

Erik Osterman - Faster Response Times By Using the Starling Queue Server

To get the slides and example code, check out this post in the meetup boards.

Each presentation was equally entertaining and informative. Thanks for providing quality content to the community guys!

Here’s a photo I found off the meetup group for your enjoyment:

Jack Bauer's office is the office on the top right in this image

Looking for some videos? Why of course!

What are people saying?

The meeting was great, all the presentations were very informative and interesting, good choice of topics. The new format definitely work, let’s keep it. The Rubicon office was pretty fancy and served good food ;-) Thanks to Will for arranging this event, it was very well organized, like usual. - Oleg Baranovsky

I enjoyed this event very much! Thanks Will for organizing this event! The presentations were engaging, and it was great meeting all of you web gurus! The food and beer was awesome too! :) - Rob Stathem

Take a look at our meetup page for more details.

Were you able to attend the meetup? What did you think of it?

Automate Your Rails Deployment

Friday, July 18th, 2008

I’m a big fan of researching and playing with new technologies (hey! I remember rails 0.7) so its no surprise that I’ve been playing a lot with Ruby Enterprise Edition and Phusion Passenger (mod_rails) and researching it as a viable rails deployment solution. For those of you who are staying with the tried and true Nginx + Mongrel, let me offer a brief introduction to Phusion Passenger (mod_rails). But first… let’s take a trip down memory lane:

Rails Deployment History

Phusion Passenger is super easy to install and setup as an Apache mod and immediately simplifies the deployment of rails. It allows you to deploy a rails application without splitting your attention between the web server and app server, such as Nginx and Mongrel. You literally upload a configuration which looks like the following block of code to Apache and it manages your rails application for you.

<VirtualHost *:80>
  ServerName  myrailssite.com
  ServerAlias www.myrailssite.com
 
  DocumentRoot /var/www/rails-project/current/public
</VirtualHost>

Passenger gives rails the same ease of deployment as mod_php and mod_perl. And when you want, it will automatically reload your app if you deploy changes.

But the real gem is using Phusion Passenger with Ruby Enterprise Edition, which is a rewrite of the Ruby MRI with optimization for mod_rails in mind. The initial benchmarks show that using both together results in lower memory usage and increased requests per second. Since then, passenger has had a myriad of early adopters reporting their results. DreamHost praised Phusion for finally solving their rails deployment, after complaining only 4 months earlier of how rails deployment options were a joke. Other websites have boarded the Phusion Passenger train too, reporting easy setup and even easier deployment.

The results look good: Dead easy rails deployment with great performance.

So how do you get started? For dead easy server provisioning, check out Sprinkle, a gem which provisions servers for you. I’ve been hard at work implementing new features and patches to Sprinkle, which you can see in my fork. I have already created the sprinkle scripts to automatically setup this entire stack on a fresh ubuntu server:

  • Rails (and Ruby, Rubygems)
  • sqlite3 or mySQL
  • Apache2
  • Phusion Passenger (mod_rails)
  • Ruby Enterprise Edition

If you’re interested in the automatic setup solution, I recommend checking out the screencast I made detailing the entire process. It requires a custom version of the sprinkle gem (from my fork), which the screencast covers.

If you plan on trying it out and have any questions, leave a comment or feel free to contact me at mitchell.hashimoto [at] citrusbyte [dot] com and I’ll happily provide any assistance you may need.

Keep your site as fresh as your code

Friday, June 27th, 2008

I am actively working on PoolParty, but the website doesn’t necessarily show that the project is in active development.

Luckily, it is hosted at github and they have an API to access their changesets. Now, on PoolParty’s website, I am surfacing the latest changeset’s time, message and author as well as a link to the changeset.

How?

Code (shortened for brevity purposes):

$:.unshift(File.dirname(__FILE__))
require "rubygems"
require "yaml"
require "open-uri"
 
class Grab
  @url = "http://github.com/api/v1/yaml/auser/pool-party/commits/master"
  @refresh_after = 20
 
  def self.latest_commit_object
    o = yaml["commits"][0]
    {
      :message => o["message"].gsub(/\n/, "<br />"),
      :date => Time.parse(o["committed_date"]).timeago,
      :by => o["committer"]["name"],
      :url => o["url"]
    }
  end
end

The github api is slick. As you can see from above, the format for the api url looks like

http://github.com/api/version/format/username/repository/type/object

Where the variables there correspond to:

  • Current version: v1
  • Acceptable formats: json, xml, yaml
  • Acceptable types: commits, commit

Grabbing the latest changesets from the url as YAML format, we can quickly and easily parse the message into a useful hash.

I personally like the “# hours ago” syntax that 2.0 sites are popping up with everywhere, so I just added a timeago method that is very similar to the one included with rails. The source is attached.

Since I don’t want poolpartyrb.com’s load time to be dependent upon how fast it can hit github, I cache the variable so every 20 views it refreshes.

Use in Rails

Save both the files (attached below) to your lib directory.

Add this to your environment.rb

require 'grab'

Then add this helper to your application_helper.rb

  def show_latest_commit
    @latest_commit = Grab.latest_commit_object
 
    <<-EOS
      <div class='note'><strong>Latest commit</strong><br />
      <a href="#{@latest_commit[:url]}">#{@latest_commit[:message]}</a>
      <div class="highlight">by #{@latest_commit[:by]}</div>
      #{@latest_commit[:date]}
    EOS
  end

How to use in sinatra

I use this on poolpartyrb.com, which is a sinatra site. I do basically the same as above, but generally render the code in haml instead

  $:.unshift(File.dirname(__FILE__))
  require "sinatra"
  require 'grab'
 
  get '/' do
    @latest_commit = Grab.latest_commit_object
    haml :home, :layout => :layout
  end

Then in my home.haml

  .note
    %strong
      Latest commit
    %br
    ==<a href="#{@latest_commit[:url]}">
    = @latest_commit[:message]
    </a>
    .highlight
      == by #{@latest_commit[:by]}
    = @latest_commit[:date]

Get the code here

edit: updated location of code

Announcing… PoolParty! An Open Source tool for managing EC2 clusters

Thursday, June 5th, 2008

Is your EC2 server pool starting to look like this?

PoolParty can help you turn it into this:

Why would I need PoolParty?

Amazon’s Elastic Compute Cloud has made it cheap and straightforward to run your own server pool, but there are various issues with volatility, lack of load balancing between instances, no persistent instance storage (currently in private beta). Also there is no mechanism for scaling your instances dynamically (ie, adding or removing instances as your load changes).

That is all taken care of by PoolParty, a recently open sourced Ruby gem and the brainchild of fellow CitrusByte developer Ari Lerner. PoolParty takes care of the following:

  • Automatic scaling based on demand and load
  • Starting/stopping instances
  • Self-healing
  • Provisioning and bootstrapping initial software
  • Setting up S3Fuse
  • Load balancing with HAProxy
  • Built-in monitoring
  • Plug-in architecture for extendability / customization

How?

PoolParty is based on established open source technologies that have been widely used in production. It takes your EC2 server pool, and invites S3Fuse, monit, and members of the High Availability Linux Project . Now you don’t just have a pool. You have a rocking pool party. All you have to do is sign those invites! (In other words: just provide a config file and you’re done).

More Information

You can check it out at the official PoolParty website. Tutorials, walk-throughs and articles are coming soon.

If you are interested in active development, check out the source at github. Active discussion is on the PoolParty Google Group

Here are the slides from the talk Ari gave at RailsConf sessions (also available here):

Read this doc on Scribd: pool party presentation