Your SlideShare is downloading. ×
Dynamic Languages Web Frameworks Indicthreads 2009
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Dynamic Languages Web Frameworks Indicthreads 2009

2,274
views

Published on

Dynamic Languages & Web Frameworks in GlassFish v3 presentation at 4th IndicThreads conference, Pune, India.

Dynamic Languages & Web Frameworks in GlassFish v3 presentation at 4th IndicThreads conference, Pune, India.

Published in: Technology

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,274
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
34
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Dynamic Languages & Web Frameworks in GlassFish v3 Arun Gupta (blogs.sun.com/arungupta, @arungupta) Sun Microsystems, Inc.
  • 2. What is a Dynamic Language ?
    • Broadly a language that allows a program to change its own code at runtime
      • Evaluate data as code ("The name is: #{@name}" )
      • 3. Manipulate code as data ({"name"=>"Duke"}.each {|data| puts data})
      • 4. High order functions
      • 5. Dynamic Typing
      • 6. Closures, Continuations, Macros, ...
    • Simple, human-readable syntax
    • 7. List, Ruby, Python, Groovy, ...
  • 8. Web Frameworks
    • Full-stack
      • Object relational mapping
      • 9. MVC-pattern
      • 10. Templating
      • 11. JavaScript library
      • 12. Extension points
    • Agile Development
      • No compile, redeploy, restart cycles
      • 13. Testing built into the framework
  • 14. Design Principles
    • Convention over Configuration (CoC)
      • Common cases easily served
      • 15. Encourages standard practices
      • 16. Everything simpler and smaller
    • Don't Repeat Yourself (DRY)
      • Framework written around minimizing repetition
  • 17. What is GlassFish ?
    • A community
      • Users, Partners, Testers, Developers, ...
      • 18. Started in 2005 on java.net
    • Application Server
      • Enterprise Quality and Open Source
      • 19. Java EE Reference Implementation
      • 20. Full Commercial Support from Sun
  • 21. Sun GlassFish Enterprise Server GlassFish Open Source Application Server Customer Focused Support Team Patches & Upgrades 24x7 Support Customer Advocate Sun VIP Interoperability Support Enterprise Manager eLearning Credit
  • 22. GlassFish v3
    • Modular:
      • Maven 2 – Build & Module description
      • 23. Felix – OSGi runtime (216 bundles)
      • 24. Allow any type of Container to be plugged
        • Start Container and Services on demand
    • Embeddable: runs in-VM
    • 25. Extensible
      • Rails, Grails, Django, ...
  • 26. GlassFish v3 Architecture GlassFish Kernel Security Rails Grails Web Config Injection Naming Grizzly Bundles Repositories HK2 Services OSGi Runtime
  • 27. Dynamic Languages & Frameworks http://glassfish-scripting.dev.java.net
  • 28.
    • Ruby interpreter written in Java
    • 29. Current Version: 1.4.0
    • 30. Ruby 1.8.6 compatible
    • 31. Some Ruby 1.9 support
      • --1.9 flag
      • 32. 80% of 1.9.1
    • 9 Active committers
    What is ? http://jruby.kenai.com/presentations/JRubyConf%2009%20Keynote.pdf
  • 33. Compatibility
    • ~37,000 passing rubyspecs
    • 34. ~22,000 passing assertions
    • 35. Continuous Integration
      • On commit ~3 Java versions * 4 vendors
      • 36. Nightly: 30 minute “full” run
  • 37.
    • Solid performance ( ͋ Ruby 1.9)
      • Startup is poor, execution usually better than 1.9
    • Runs native threads
    • 38. Foreign Function Interface (FFI) for C libraries
    • 39. Runs Rails great!
  • 40.
    • Full-stack Web development MVC framework in Ruby
    • 41. Current Version: Rails 2.3.4
    • 42. Getting Started
      • Install Rails: “jruby -S gem install rails”
      • 43. Generate Rails app: “jruby -S rails helloworld”
    What is ?
  • 44. Rails Deployment Choices Credits: http://birdwatchersdigest.com
  • 45. Directory-based Deployment: How ? jruby -S rails helloworld asadmin start-domain asadmin create-jvm-options -DJRUBY_HOME=... asadmin deploy railsconf
  • 46. Directory-based: Capistrano Recipes http://wiki.glassfish.java.net/Wiki.jsp?page=DeployUsingCapsitrano
  • 47. Rails Development using NetBeans 6.8 http://blogs.sun.com/arungupta/entry/screencast_26_develop_run_debug
  • 48. Rails Deployment: GlassFish Gem
  • 49. GlassFish Gem: How ? jruby -S rails helloworld jruby -S gem install glassfish cd helloworld jruby -S glassfish
  • 50. Single Threaded Rails < v 2.2
  • 51. Multi Threaded Rails or Merb or ...
  • 52. GlassFish Gem: Capistrano Recipes http://wiki.glassfish.java.net/Wiki.jsp?page=DeployUsingCapsitrano
  • 53. GlassFish Gem Options jruby -S glassfish -h -n: Number of JRuby runtimes to create initially --runtimes-min: Minimum runtimes --runtimes-max: Maximum runtimes -c : change the context root -e : environment -d : Runs as daemon -P : location of PID file -l : log file location -log-level : Logging level (0-7)
  • 54. Demo GlassFish Gem http://blogs.sun.com/arungupta/entry/totd_76_jruby_1_2
  • 55. GlassFish Gem in Production
    • Easy, green deployment
      • Reverse proxy not required
      • 56. JRuby runtime pool provides required scaling
        • Rails is single threaded by default
      • MT frameworks scales automatically
        • JRuby and JVM support native threads
    • Configuration using “glassfish.yml”
  • 57. Optional front-ending http://blogs.sun.com/arungupta/entry/totd_81_how_to_use http://blogs.sun.com/arungupta/entry/totd_84_using_apache_mod
  • 58. Rails Deployment: WAR-based
  • 59. WAR-based: How ? jruby -S gem install warbler cd helloworld jruby warble config Edit “config/warble.rb” Include gems, Change RAILS_ENV jruby warble asadmin deploy helloworld.war jruby -S rails helloworld
  • 60. WAR Deployment: Packaging
  • 61. Demo WAR-based Deployment http://blogs.sun.com/arungupta/entry/totd_73_jruby_and_glassfish
  • 62. JRuby Module on GlassFish Update Center
  • 63. Ruby Rack Support
    • Rack - A Web server interface
    • 64. Plugin any Rack compliant framework
      • Rails, Merb, Sinatra, Ramaze, Campsite, ...
    • Rack support in GlassFish
      • GlassFish Gem
        • Plugin any Rack metal (such as RackCache)
      • GlassFish v2 & v3 through Warbler
    • Use your own framework
      • Rackup script
      • 65. jruby.applicationType property
  • 66. Ruby Application Auto-detection
  • 67. Performance
    • Need JVM tuning for production
      • Use Server profile where possible (- server )
    • GC settings
      • -XX:+DisableExplicitGC, -XX:NewRatio=2
    • Memory settings
      • Use large settings for -Xmx -Xms and -XX:MaxPermSize
      • 68. Use at least 20 MB perm gen space for each JRuby runtime
  • 69. Scaling
    • Rails is single-threaded by default
    • 70. Setup JRuby runtime pool
      • With gem
        • glassfish -n 3 –runtime-min 2 –runtime-max 4
    • 2 HTTP Worker Threads per runtime
    • 71. Turn on file caching
      • network-config>protocols>protocol>http>file-cache#enabled
    • MT frameworks (Rails > 2.2, Merb)
      • No configuration needed
  • 72. Rails Monitoring
    • Basic Monitoring
      • jinfo : System properties and VM CLI flags
      • 73. jmap : Shared object memory map
      • 74. jstack : Stack traces of Java threads
      • 75. jstat : Performance stats on class, JIT compiler, GC
    • Advanced
      • jconsole / Visual VM
      • 76. NewRelic, FiveRuns, ...
  • 77. Rails Monitoring in GlassFish v3
    • asadmin enable-monitoring –level jruby-container=HIGH
    • 78. asadmin list –monitor=true “*”
    • 79. asadmin list –monitor=true “*jruby*”
    • 80. asadmin list-probes | grep jruby
    • 81. dtrace or JavScript-based monitoring
    http://blogs.sun.com/arungupta/entry/totd_104_glassfish_v3_monitoring
  • 82. Endorsements Look like the best deploying option I ever found for Rails, GREAT! the easiest rails stack in the world, jruby 1.2rc, rails 2.3rc, glassfish v3 ... too easy to run jruby/rack/ glassfish behind nginx leading the way to simple, scalable, no-hassle hosting for Ruby web applications. ... 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! nice way to deploy and manage my app while leaving things open for scaling
  • 83. Who loves Rails on GlassFish ?
  • 84.  
  • 85. What is ?
    • Agile dynamic language for the JVM
    • 86. Seamlessly integrates with all existing Java objects & libraries
      • Compiles straight to bytecode
    • Current version: 1.6.7
    • 87. groovy -e &quot;println 'Hello ' + args[0]&quot; World
  • 88. What is ?
    • MVC Web framework for the Java platform
      • Persistence framework (Hibernate)
      • 89. Templating using GSP (Groovy Server Pages)
      • 90. Tag libraries to create web page components
      • 91. Good Ajax support
      • 92. Web server & automatic resources reload
    • Current Version: 1.1.2, 1.2 RC1 released 12/5
  • 93. Grails “Hello World”
    • Create app: “grails create-app bookstore”
      • Create domain class: “grails create-domain-class book”
      • 94. Edit “grails-app/domain/Book.groovy” and add attributes
      • 95. Create controller: “grails create-controller Book”
      • 96. Edit “grails-app/controllers/BookController.groovy”
      • 97. Add scaffold: “def scaffold = Book”
    • Run app: “grails run-app”
  • 98. Grails on GlassFish App Server
    • Create WAR: “grails war”
    • 99. Deploy: “asadmin deploy helloworld-0.1.war”
  • 100. Demo Grails & GlassFish http://blogs.sun.com/arungupta/entry/getting_started_with_grails_on http://blogs.sun.com/arungupta/entry/totd_75_getting_started_with http://blogs.sun.com/arungupta/entry/grails_on_glassfish_v3_embedded http://blogs.sun.com/arungupta/entry/tic_tac_toe_using_rails
  • 101. Grails Module on GlassFish Update Center
  • 102. Efficient Deployment
    • Grails Application WAR
      • Large
        • Over 48 Grails dependent JARs
        • 103. ~20MB for a simple app
      • Expensive to bundle in single WAR
      • 104. Issues when hot deployment is required
  • 105. GlassFish proposes light-weight WAR
    • Don't package dependencies!
    • 106. Smaller WAR file: ~200KB vs ~20MB
    • 107. GlassFish knows how to find dependencies
    • 108. Only one copy of dependencies in GlassFish
      • Less memory consumption and deployment speed-up
    • $ grails shared-war
    • 109. With Grails 1.1 use –nojars option
    • 110. $ asadmin deploy helloworld-0.1.war
  • 111. GlassFish/Grails: Coming up ...
    • Use “grails –nojars”
      • JIRA-5174, JIRA-5175
    • “grails install-plugin glassfish –global”
      • grails run-app
    • “asadmin deploy grailsApp”
  • 112.  
  • 113. What is ?
    • Implementation of Python in Java
      • Seamless integration of Python and Java
      • 114. Java <==> Python
      • 115. Just Python
      • 116. Dynamic compilation to Java bytecodes
    • Jython 2.5.1 released (Sep 2009)
    • 117. Works with Django 1.0
  • 118. What is ?
    • MVC-based framework written in Python
      • Object-relational mapper
      • 119. A lightweight, standalone Web server
      • 120. A regular expression based URL dispatcher
      • 121. A templating system
      • 122. A caching framework
      • 123. An internationalization system
      • 124. . . .
  • 125. GlassFish Deployment
    • Deploy as WAR
      • Modjy
        • Servlet, ServletContextListener + WSGI Implementation
        • 126. Integrated with Jython 2.5
    • Pure Django Deployment
      • Grizzly + WSGI => Django
      • 127. No WAR, no packaging
      • 128. asadmin deploy myDjangoApp
  • 129. How does it work ?
    • Download Jython
    • 130. Install Django (jython25 setup.py install)
    • 131. GlassFish v3 Jython OSGi module from UC
    • 132. asadmin create-jvm-options -Djython.home=...
    • 133. cd DjangoApp
    • 134. asadmin deploy .
  • 135. Jython Module on GlassFish Update Center
  • 136. Demo Django & GlassFish http://blogs.sun.com/arungupta/entry/totd_85_getting_started_with
  • 137. http://blogs.sun.com/arungupta/entry/tic_tac_toe_using_rails
  • 138. Java EE & Dynamic Languages
    • JavaEE is a mature and robust platform
      • Servlet, EJB, JMS, JAX-RS, JAX-WS...
    • Hybrid Rails and Servlet/JSP application
      • Forward to and from Rails to Servlet/JSP
      • 139. HTTPSession as Rails session
      • 140. ServletRequest/Response API available to Rails
    • JDBC connection pool
    • 141. JMS: Async messaging in Rails
  • 142. Servlet 3.0 Pluggability
    • JavaEE 6 and Dynamic Languages
      • No boilerplate web.xml
      • 143. Dynamically add ServletFilter and ServletContextListener
    • Simple packaging
      • No need to package as WAR, No Warbler
      • 144. Place application inside WEB-INF directory
  • 145. References
    • glassfish.org
    • 146. glassfish-scripting.dev.java.net
    • 147. sun.com/glassfish
    • 148. blogs.sun.com/theaquarium
    • 149. twitter.com/glassfish
    • 150. [email_address]
  • 151. Dynamic Languages & Web Frameworks in GlassFish v3 Arun Gupta (blogs.sun.com/arungupta, @arungupta) Sun Microsystems, Inc.