The Other mod_rails: Easy Rails Deployment with JRuby. Nick Sieger Sun Microsystems, Inc



Similar documents
Pete Helgren Ruby On Rails on i

Evaluation. Chapter 1: An Overview Of Ruby Rails. Copy. 6) Static Pages Within a Rails Application

Ruby on Rails in GlassFish Sun Microsystems

Apache Thrift and Ruby

Achieving High Throughput. Fernando Castano Sun Microsystems

Rails Application Deployment. July Philly on Rails

No.1 IT Online training institute from Hyderabad URL: sriramtechnologies.com

WEBAPP PATTERN FOR APACHE TOMCAT - USER GUIDE

Sample copy. Introduction To WebLogic Server Property of Web 10.3 Age Solutions Inc.

Building and Deploying Web Scale Social Networking Applications Using Ruby on Rails and Oracle. Kuassi Mensah Group Product Manager

Integrate Rails into an Existing IIS Web infrastructure using Mongrel

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

Certified Redmine Project Management Professional Sample Material

JRuby Now and Future Charles Oliver Nutter JRuby Guy Sun Microsystems

Installing Rails 2.3 Under CentOS/RHEL 5 and Apache 2.2

Installing Rails 2.3 Under Windows XP and Apache 2.2

MID-TIER DEPLOYMENT KB

Deploying and Monitoring Ruby on Rails A practical guide

Ruby on Rails (Ruby 1.9.2, Rails 3.1.1) Installation

ITG Software Engineering

Learning GlassFish for Tomcat Users

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

Crawl Proxy Installation and Configuration Guide

The NetBeans TM Ruby IDE: You Thought Rails Development Was Fun Before

The Ruby Application Platform

Blackboard Learn TM, Release 9 Technology Architecture. John Fontaine

Oracle Weblogic. Setup, Configuration, Tuning, and Considerations. Presented by: Michael Hogan Sr. Technical Consultant at Enkitec

Tuning Your GlassFish Performance Tips. Deep Singh Enterprise Java Performance Team Sun Microsystems, Inc.

How To Run A Hello World On Android (Jdk) On A Microsoft Ds.Io (Windows) Or Android Or Android On A Pc Or Android 4 (

Basic TCP/IP networking knowledge of client/server concepts Basic Linux commands and desktop navigation (if don't know we will cover it )

Operations and Monitoring with Spring

Don t get it right, just get it written.

APACHE WEB SERVER. Andri Mirzal, PhD N

Why Threads Are A Bad Idea (for most purposes)

MagDiSoft Web Solutions Office No. 102, Bramha Majestic, NIBM Road Kondhwa, Pune Tel: /

Various Load Testing Tools

Robert Honeyman

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Oracle WebLogic Server 11g Administration

Apache Jakarta Tomcat

Ruby on Rails is a web application framework written in Ruby, a dynamically typed programming language The amazing productivity claims of Rails is

IBM WebSphere Server Administration

WebSphere Server Administration Course

Installing Ruby on Windows XP

Scaling Progress OpenEdge Appservers. Syed Irfan Pasha Principal QA Engineer Progress Software

Configuring Apache Derby for Performance and Durability Olav Sandstå

Jérôme Lepage - CFCamp Mondadori France

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

Configuring Nex-Gen Web Load Balancer

Kony MobileFabric. Sync Windows Installation Manual - WebSphere. On-Premises. Release 6.5. Document Relevance and Accuracy

ServletExec TM 6.0 Installation Guide. for Microsoft Internet Information Server SunONE Web Server Sun Java System Web Server and Apache HTTP Server

Glassfish, JAVA EE, Servlets, JSP, EJB

An Oracle White Paper May Ready for Business: Oracle GlassFish Server

<Insert Picture Here> GlassFish v3 - A Taste of a Next Generation Application Server

WebLogic Server: Installation and Configuration

New Relic & JMeter - Perfect Performance Testing

GlassFish Security. open source community experience distilled. security measures. Secure your GlassFish installation, Web applications,

Oracle EXAM - 1Z Oracle Weblogic Server 11g: System Administration I. Buy Full Product.

AGENDA. Introduction About Weblogic Server Weblogic Server Administration Top Ten Concepts Q & A

NGASI Universal APP Panel Administration and User Guide WebAppShowcase DBA NGASI

Tomcat 5 New Features

Determine the process of extracting monitoring information in Sun ONE Application Server

The enterprise class monitoring solution for everyone

Using the Adobe Access Server for Protected Streaming

Enterprise Manager. Version 6.2. Installation Guide

Proposal for Virtual Private Server Provisioning

Optimize GlassFish Performance in a Production Environment Performance White Paper February Abstract

Oracle WebLogic Server

Cloud Computing. Adam Barker

KonyOne Server Installer - Linux Release Notes

Enabling the Information Age

DBI-Link: 3.0. PgCon Ottawa 2008 Copyright David Fetter 2008 All Rights Reserved

Mastering Tomcat Development

Internet Information TE Services 5.0. Training Division, NIC New Delhi

DBX. SQL database extension for Splunk. Siegfried Puchbauer

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

24x7 Scheduler Multi-platform Edition 5.2

OpenMind: Know Your Customer

JBoss AS Administration Console User Guide. by Shelly McGowan and Ian Springer

Tivoli Log File Agent Version Fix Pack 2. User's Guide SC

Using MySQL for Big Data Advantage Integrate for Insight Sastry Vedantam

GlassFish OpenSSO CAC Authentication Deployment Configuration Guide

RED HAT SOFTWARE COLLECTIONS BRIDGING DEVELOPMENT AGILITY AND PRODUCTION STABILITY

Lecture 6 Cloud Application Development, using Google App Engine as an example

HP OO 10.X - SiteScope Monitoring Templates

Witango Application Server 6. Installation Guide for OS X

Liferay Performance Tuning

MarkLogic Server. Administrator s Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

Web Server Configuration Guide

NetBeans IDE Field Guide

PeopleSoft Online Performance Guidelines

Glassfish Architecture.

1Z Oracle Weblogic Server 11g: System Administration I. Version: Demo. Page <<1/7>>

Deployment and Monitoring. Pascal Robert MacTI

Oracle Enterprise Manager 12c Cloud Control for Managing Oracle E-Business Suite 12.2

Ruby on Rails. a high-productivity web application framework. blog.curthibbs.us/ Curt Hibbs <curt@hibbs.com>

Transcription:

The Other mod_rails: Easy Rails Deployment with JRuby Nick Sieger Sun Microsystems, Inc

CGI/FCGI

Mongrel

omg puppiez!

not nirvana...

Processes: 68 total, 3 running, 1 stuck, 64 sleeping... 309 threads Load Avg: 0.71, 0.51, 0.43 CPU usage: 22.79% user, 13.02% sys, 64.19% idle SharedLibs: num = 8, resident = 80M code, 384K data, 5156K linkedit. MemRegions: num = 13190, resident = 707M + 27M private, 400M shared. PhysMem: 589M wired, 1205M active, 89M inactive, 1883M used, 2197M free. VM: 11G + 373M 188123(0) pageins, 0(0) pageouts PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE 650 top 6.3% 0:01.71 1 18 29 1084K 188K 1676K 18M 571 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 572 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 573 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 574 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 575 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 576 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 577 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 578 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 579 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 580 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 581 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 582 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 583 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 584 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 585 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 586 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 587 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 588 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 589 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 580 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M 591 ruby 0.2% 0:04.09 2 17 163 32M 188K 34M 51M

Webserver/Load Balancer Mongrel Rails Ruby Mongrel Rails Ruby Mongrel Rails Ruby Key Rails Ruby code OS Proc.

HTTP Listener GlassFish HTTP Listener HTTP Listener Servlet Bridge Rails JRuby Rails JRuby JVM Rails JRuby Key Rails Java code OS Proc.

existing applications

$ jruby -S gem install activerecord-jdbcmysql-adapter Successfully installed activerecord-jdbc-adapter-0.8 Successfully installed jdbc-mysql-5.0.4 Successfully installed activerecord-jdbcmysql-adapter-0.8 3 gems installed Installing ri documentation for activerecord-jdbc-adapter-0.8... Installing ri documentation for jdbc-mysql-5.0.4... Installing ri documentation for activerecord-jdbcmysql-adapter-0.8... Installing RDoc documentation for activerecord-jdbc-adapter-0.8... Installing RDoc documentation for jdbc-mysql-5.0.4... Installing RDoc documentation for activerecord-jdbcmysql-adapter-0.8...

# config/database.yml <% jdbc = defined?(jruby_version)? 'jdbc' : '' %> development: adapter: <%= jdbc %>mysql encoding: utf8 database: testapp_development username: root password: socket: /tmp/mysql.sock # same for test/production...

Gems and libraries with native code

http://flickr.com/photos/thehappyrobot/1413968365/

replacements/ equivalents Mongrel, Hpricot OK RMagick, ImageScience ImageVoodoo JRuby- OpenSSL OpenSSL gem Ruby/LDAP JRuby/LDap

$ jruby -S gem install mongrel Successfully installed mongrel-1.1.3-java 1 gem installed Installing ri documentation for mongrel-1.1.3-java... Installing RDoc documentation for mongrel-1.1.3-java... $ jruby script/server => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel 1.1.3 available at 0.0.0.0:3000 ** Use CTRL-C to stop.

packaging

warbler

jruby -S gem install warbler jruby -S warble config

# Warbler web application assembly configuration file Warbler::Config.new do config #... # Gems to be packaged in the webapp.... config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"] config.gems["rails"] = "2.0.2" #... end

warbler demo

configuration

logging if defined?(jruby_version) && defined?($servlet_context) # Logger expects an object that responds to #write and #close device = Object.new def device.write(message) $servlet_context.log(message) end def device.close; end # Make these accessible to wire in the log device class << RAILS_DEFAULT_LOGGER public :instance_variable_get, :instance_variable_set end old_device = RAILS_DEFAULT_LOGGER.instance_variable_get "@log" old_device.close rescue nil RAILS_DEFAULT_LOGGER.instance_variable_set "@log", device end

sessions config.action_controller.session_store = :java_servlet_store #... class CGI::Session::JavaServletStore def initialize(session, options) end def restore; end def update; end def close; end end

connection pools # config/initializers/close_connections.rb if defined?($servlet_context) require 'action_controller/dispatcher' ActionController::Dispatcher.after_dispatch do ActiveRecord::Base.clear_active_connections! end end

view caching config.action_view.cache_template_loading = true (default in Rails >= 2.0.2)

asset timestamps ENV['RAILS_ASSET_ID'] = "r#{source_revision}"

full-page cache config.action_controller.page_cache_directory = "/where/is/my/railsapp/war/deployed" Rails.public_path coming in 2.1

if defined?(jruby_version) && defined?($servlet_context) # Logger expects an object that responds to #write and #close device = Object.new def config.action_controller.session_store device.write(message) = :java_servlet_store $servlet_context.log(message) end #... # config/initializers/close_connections.rb def device.close; if defined?($servlet_context) end class CGI::Session::JavaServletStore require 'action_controller/dispatcher' # Make these accessible to wire in the log device def config.action_view.cache_template_loading initialize(session, options) end = true class ENV['RAILS_ASSET_ID'] << config.action_controller.page_cache_directory ActionController::Dispatcher.after_dispatch RAILS_DEFAULT_LOGGER = "r#{source_revision}" do = def restore; "/where/is/my/railsapp/war/deployed" end public :instance_variable_get, ActiveRecord::Base.clear_active_connections! :instance_variable_set end def update; end end def end close; end old_device end = RAILS_DEFAULT_LOGGER.instance_variable_get "@log" old_device.close rescue nil RAILS_DEFAULT_LOGGER.instance_variable_set "@log", device end

jruby-rack

available now released earlier this month

bundled with warbler

servlet adapter

eliminates previous configuration

http://rack.rubyforge.org/

proc do env [200, {"Content-Type" => "text/html"}, "Hello World!"] end

middleware

module Rack class ShowStatus def initialize(app) @app = app @template = ERB.new(TEMPLATE) end def call(env) status, headers, body = @app.call(env) if status.to_i >= 400 [status, headers.merge("content-type" => "text/html"), [@template.result(binding)]] else [status, headers, body] end end end end

rack demo

tuning

http://flickr.com/photos/86974734@n00/2206011624/

pool size Warbler::Config.new do config #... # Control the pool of Rails runtimes config.webxml.jruby.min.runtimes = 2 config.webxml.jruby.max.runtimes = 4 end

performance misattribution

lies, damned lies

YMMV

measure your own @#$!& app

75 Request Scaling (1 process or runtime) 60 avg reply rate 45 30 15 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 request rate webrick mongrel glassfish

Warbler::Config.new do config #... # Control the pool of Rails runtimes config.webxml.jruby.min.runtimes = 1 config.webxml.jruby.max.runtimes = 1 end

Warbler::Config.new do config #... # Control the pool of Rails runtimes config.webxml.jruby.min.runtimes = 3 config.webxml.jruby.max.runtimes = 3 end

200 JRuby/Glassfish 175 150 Avg reply rate 125 100 75 50 25 0 1 runtime (interpolated above 90) 3 runtimes 15 30 45 60 75 90 105 120 135 150 165 180 195 210 225 240 255 270 285 300 Request rate

the future is now

rails concurrency Each Rails request must execute in isolation. Rails is not thread-safe? WTF? Servlets have been multi-threaded since, like,1997!

concurrency context Writing thread-safe code is hard + Ruby's userland threads don't yield much benefit Not worth the effort

but what if it was?

Rails to become thread-safe (Google SoC 2008 project)

connection pooling for ActiveRecord (yours truly)

Rails on a Rack? Ezra s work: http://github.com/ezmobius/rails/

rails rack native threading connection pooling single-file deployment + industrial-strength vm

=

she s a beaut.

hassle-free

scalable

(enterprisey?)

awesome! (stay tuned!)