An Evaluation of Current Ruby on Rails Serving

cabbagepatchtapeInternet and Web Development

Feb 5, 2013 (4 years and 6 months ago)

157 views

An Evaluation of Current Ruby on Rails
Serving Approaches


Jeremy Witmer


CS 526

Spring 2008

Overview

1.
Purpose

2.
Introduction

3.
Application Servers

4.
Reverse Proxies

5.
Procedure

6.
Benchmarking

7.
Results

8.
Conclusions

9.
Future Research


5.5.2008

Ruby on Rails Application Serving
CS526

2

Purpose

The purpose of this project is to survey the current best
application servers for Ruby on Rails, and best methods for
reverse proxy to a cluster of application servers.

5.5.2008

Ruby on Rails Application Serving
CS526

3

Introduction


What is Ruby?


Ruby is a dynamically typed object
-
oriented
programming language with significant
metaprogramming capabilities


What is JRuby?


JRuby is an implementation of Ruby that runs on the
Java Virtual Machine (JVM)


What is Rails?


Rails is a web application development framework
written Ruby, which uses the metaprogramming
capabilities of Ruby to ease development effort.

5.5.2008

Ruby on Rails Application Serving
CS526

4

Rails Application Serving

5.5.2008

Ruby on Rails Application Serving
CS526

5

Application Servers


WEBrick


Mongrel


Thin

5.5.2008

Ruby on Rails Application Serving
CS526

6

Reverse Proxies


Apache 2


nginx


Pound


Swiftiply


Glassfish

5.5.2008

Ruby on Rails Application Serving
CS526

7

Procedure


1. Set up a basic Rails application (used gullery)


2. Run a single instance of each application server and
benchmark the throughput


3. For each of the reverse proxy options:


1. Set up the reverse proxy to dispatch to the cluster


2. Run a cluster of 3 Mongrels, first on Ruby, then on JRuby


3. Run the benchmarks to measure cluster throughput

4. Set up gullery application to run on Glassfish under JRuby and
run the same benchmarks

5.5.2008

Ruby on Rails Application Serving
CS526

8

Benchmarking


All benchmarks performed using RubyWebBench


RWB allows scripting requests and weighting among URLs
in the application


Each cluster setup was tested 3 times with 1000 requests


urls.add_url(20, "http://localhost:3500")

urls.add_url(40, "http://localhost:3500/projects/show/1")

urls.add_url(40, "http://localhost:3500/projects/show/1")



5.5.2008

Ruby on Rails Application Serving
CS526

9

Results

Application Servers, 1000 Request Benchmark

5.5.2008

Ruby on Rails Application Serving
CS526

10

Software

Platform

Total Time

Requests/Second

Mean

Time/

Request (ms)

WEBrick

Ruby

31.9797

31.2697

159

WEBrick

JRuby

54.6763

18.2894

272

Thin

Ruby

28.4653

35.1304

142

Mongrel

Ruby

30.8750

32.3885

154

Mongrel

JRuby

46.8135

21.3613

233

Results

Reverse Proxies to Clusters, 1000 Request Benchmark

5.5.2008

Ruby on Rails Application Serving
CS526

11

Software

Platform

Total Time

Requests/Second

Mean

Time/

Request (ms)

Apache2

Ruby

16.6153

60.1851

82

Apache2

JRuby

15.6863

63.7495

78

nginx

Ruby

16.6326

60.1226

82

nginx

JRuby

19.4436

51.4306

97

Pound

Ruby

16.6878

59.9239

83

Pound

JRuby

17.1875

58.1815

85

Swiftiply

Ruby

only

18.2185

54.8891

90

GlassFish

JRuby only

1.1563

864.7653

5

GlassFish

100,000 Req.

201.4331

496.4425

10

Conclusions


Use GlassFish


Use Thin on native Ruby, with Apache2


Ruby and JRuby are pretty close in terms of performance


JRuby takes longer to start, but does better in terms of
memory and processor usage


JRuby doesn’t have a user
-
space threading problem

5.5.2008

Ruby on Rails Application Serving
CS526

12

Future Work


Benchmark modrails as an application server/proxy


Benchmark haProxy for reverse proxying


Compare results to hardware reverse proxy/load balancers

5.5.2008

Ruby on Rails Application Serving
CS526

13

Wiki, Files, and Scripts


Wiki is at cs.uccs.edu/~jtwitmer/cs526/Project/


Project report


Setup instructions for Rails application


Setup Instructions for all application servers and proxies


Wiki generated with Instiki: rubyforge.org/projects/instiki/


Files at cs.uccs.edu/~jtwitmer/cs526/Project/FilesAndScripts.html

5.5.2008

Ruby on Rails Application Serving
CS526

14

5.5.2008

Ruby on Rails Application Serving
CS526

15

References


Ruby: ruby
-
lang.org


JRuby: jruby.codehaus.org


RubyWebBench: http://rubyforge.org/projects/rwb/


Ruby on Rails: rubyonrails.com


Mongrel: mongrel.rubyforge.org


Thin: code.macournoyer.com/thin/


Apache2: apache.org


nginx: nginx.net


Pound: www.apsis.ch/pound/


Swiftiply: swiftiply.swiftcore.org/


GlassFish: wiki.jruby.org/wiki/JRuby_on_Rails_in_GlassFish