30
Rails powered by GlassFish Arun Gupta blogs.sun.com/arungupta [email protected]

Rails powered by GlassFish

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Rails powered by GlassFish

Rails powered by GlassFish

Arun Guptablogs.sun.com/[email protected]

Page 2: Rails powered by GlassFish

What is GlassFish ?

! A Community

- Users, Partners, Testers, Developers, ...

- Started in 2005 on java.net

! Application Server

- Enterprise Quality and Open Source

- Java EE 5 Reference Implementation

- Full Commercial support from Sun

! Growing Organically into other Middleware Areas

Page 3: Rails powered by GlassFish

State of GlassFish

! GlassFish v2 – Fast, Easy, Reliable

- Java EE 5 compliant with advanced enterprise features

- Centralized Administration

- .NET 3.0 Interoperability

- High Availability, Clustering, Load Balancing

- NetBeans, Eclipse, IntelliJ integration

! GlassFish v3 – Modular, Embeddable, Extensible

- Modular: OSGi compliant, Maven 2

- Embeddable: Runs in-VM

- Extensible: Pluggable Container

! Enterprise Support and Services in “Sun GlassFish Enterprise Server”

Page 4: Rails powered by GlassFish

GlassFish v3 Gem

jruby -S gem install glassfishjruby -S glassfish_rails <RAILS_APP>

http://blogs.sun.com/arungupta/entry/jruby_1_1_3_released

Page 5: Rails powered by GlassFish

Gem Internals

2.68 MB

0.3.1

Development & Deployment

v3 NucleusGrizzly Rails

AdapterRails Connector

Auto-configurable Runtime Pool *

Page 6: Rails powered by GlassFish

GlassFish Rails Runtime Pooling

CreateJRuby

Runtime

GemStartup

Load RailsEnvironment

Add toRuntime

Pool

JRuby

Rails

JRuby

Rails

Page 7: Rails powered by GlassFish

Auto-configure Runtime Pool

GrizzlyListener

RailsAdapter

RuntimePool

borrows / add

Heuristic: Upto 2x CoreUser specified: jruby.runtime.min/max

Scalabilit

y

JRuby

Rails

Efficie

ncy

http://blogs.sun.com/Jacobkessler/entry/it_s_dynamic

Page 8: Rails powered by GlassFish

GlassFish v3

asadmin deploy <RAILS_APP>

http://blogs.sun.com/arungupta/entry/jruby_1_1_3_releasedhttp://blogs.sun.com/arungupta/entry/netbeans_6_5_m1_glassfish

Page 9: Rails powered by GlassFish

GlassFish v3 Runtime

Grizzly Listener

RailsAdapter

WebAdapter

XXXAdapter

RuntimePoolJRuby

Rails

. . .

Page 10: Rails powered by GlassFish

Concurrency Level: 2Time taken for tests: 58.227726 secondsComplete requests: 1000Failed requests: 0Write errors: 0Total transferred: 4200000 bytesHTML transferred: 3675000 bytesRequests per second: 17.17 [#/sec] (mean)Time per request: 116.455 [ms] (mean)Time per request: 58.228 [ms] (mean, across all concurrent requests)Transfer rate: 70.43 [Kbytes/sec] receivedConcurrency Level: 2

Time taken for tests: 59.395294 secondsComplete requests: 1000Failed requests: 0Write errors: 0Total transferred: 4309000 bytesHTML transferred: 3795000 bytesRequests per second: 16.84 [#/sec] (mean)Time per request: 118.791 [ms] (mean)Time per request: 59.395 [ms] (mean, across all concurrent requests)Transfer rate: 70.85 [Kbytes/sec] received

Page 11: Rails powered by GlassFish

WAR-based Deployment

! JRuby CLI

- jruby -S gem install warbler

- jruby -S warble

! NetBeans IDE

- Goldspike in NB 6.1, Warbler in NB 6.5

! Deploy Directly on GlassFish v2 or v3

c

http://blogs.sun.com/arungupta/entry/rails_and_java_ee_integration1

Page 12: Rails powered by GlassFish

JDBC Connection Pooling

production: adapter: mysql database: jndi_rails_production username: root password: host: localhost

production: adapter: jdbc jndi: jdbc/jndi_rails driver: com.mysql.jdbc.Driver

production: adapter: mysql database: jndi_rails_production username: root password: host: localhost

http://blogs.sun.com/arungupta/entry/totd_9_using_jdbc_connection

Page 13: Rails powered by GlassFish
Page 14: Rails powered by GlassFish
Page 15: Rails powered by GlassFish

Rails and Comet - Tic Tac Toe

! Multi-player game

! Using GlassFish Comet

http://blogs.sun.com/arungupta/entry/tic_tac_toe_using_rails

Page 16: Rails powered by GlassFish

Some tested apps ...

Project Management

E-Commerce Platform

Blogging System

Blogging Engine

Page 17: Rails powered by GlassFish

Gem2 load-balanced T2000, Solaris

10, AS 9.1 UR1, MySQL

AS 9.1 UR1, Dell 1750, CentOS 4.5

4 AS 9.1 UR2 instances, 16 runtimes

Ubuntu 8.04, 2 instances of GlassFish UR1 on quad-

core Xeons, Master/Slave, nginx for static files

Warbler, GlassFish v2

Warbler, GlassFish v2

http://wiki.glassfish.java.net/Wiki.jsp?page=JRuby#section-JRuby-SuccessStories

Page 18: Rails powered by GlassFish
Page 19: Rails powered by GlassFish

Hudson and JRuby

Credits: David Calavera

Credits: blog.huikau.com

Page 20: Rails powered by GlassFish

Endorsements

Look like the best deploying option I ever

found for Rails, GREAT!

The combination of Rails 2.0.2 (stable), JRuby 1.1 RC2, the Glassfish gem, and JDK 1.6 is not only breaking down enterprise barriers but speeding

up apps all over the place

leading the way to simple, scalable, no-hassle hosting for Ruby

web applications.

No mongrel packs to manage, no cluster of apps to monitor, and no WAR file relics to slow you down. "glassfish_rails myapp" and you're done; it's true one-step

deployment.

had no reliability and performance issues with

Glassfish

money is on JRuby (and Glassfish) for the long haul; if you haven't checked

out Glassfish yet, you're doing yourself a disservice!

Page 21: Rails powered by GlassFish

Rails Monitoring ?

! Basic Monitoring

- jinfo – Prints Java System properties and VM CLI flags

- jmap – Shared object memory map or heap memory details

- jstack – Stack traces of Java threads

- jstat – Performance statistics on class, JIT compiler, GC

! Deep Dive

- jconsole / VisualVM

- NewRelic

- Five Runs

Page 22: Rails powered by GlassFish

jconsole

Page 23: Rails powered by GlassFish

jconsole

Page 24: Rails powered by GlassFish
Page 25: Rails powered by GlassFish

GlassFish Deployment

blogs.sun.com/stories

Page 26: Rails powered by GlassFish

Some GlassFish Adoption Indicators

! 2.5m+ hits in 13 months

! 310k+ different IPs

! 150k registrations in 7 months

! 4.5m+ downloads in 12 months

Page 27: Rails powered by GlassFish

Host Your Rails Apps on

GlassFish, Free for 12 Months! Cloud computing

environment powered by Sun and Solaris OS- 1/16th of a quad-core

CPU- 512MB RAM- 50 GB of storage- Unmetered bandwith

data transferring- Pre-installed and

configured GlassFish and MySQL

! Free for 12 months for Sun Startup Essentials members! sun.com/startup/glassfish

Page 28: Rails powered by GlassFish

Rails 2.2

! Simple Rails App (1 Model, 1 Controller)

- 1000 requests with 10 concurrent users

10 instances Multi-threaded

200 Mb 50 Mb

233 Mb 55 Mb

Startup

Heap (at end)

Page 29: Rails powered by GlassFish

Why Rails on GlassFish ?

! Java EE is tested platform – Co-host Java and Rails

- Known Deployment and Management

- Clustering, Load Balancing and High Availability

! “Green” alternative – One command, One instance, One process

! Multiple Requests by a Single Application

! Multiple Applications in One Container

! Database Connection Pooling

http://developers.sun.com/appserver/reference/techart/rails_gf/

Page 30: Rails powered by GlassFish

Rails powered by GlassFish

Arun Guptablogs.sun.com/[email protected]