Deploying with JRuby
Deliver Scalable Web Apps Using the JVM
by Joe Kutner
Version: P1.0 (July 2012)
Copyright 2012 The Pragmatic Programmers, LLC. This book is licensed tothe individual who purchased it. We don't copy-protect itbecause that would limit your ability to use it for yourown purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copywith other members of your team, with friends, or via file sharing services. Thanks.
Dave & Andy.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Table of Contents
Copyright 2012, The Pragmatic Bookshelf.
Early Praise for Deploying JRuby
Deploying with JRuby is the definitive text on getting JRuby applications up and running. Joe has pulled together a great collection of deployment knowledge, and the JRuby story is much stronger as a result.
Charles Oliver Nutter |
JRuby Core team member and coauthor, Using JRuby |
Deploying with JRuby answers all of the most frequently asked questions regarding real-world use of JRuby that I have seen, including many we were not able to answer in Using JRuby . Whether youre coming to JRuby from Ruby or Java, Joe fills in all the gaps youll need to deploy JRuby with confidence.
Nick Sieger |
JRuby Core team member and coauthor, Using JRuby |
This book is an excellent guide to navigating the various JRuby deployment options. Joe is fair in his assessment of these technologies and describes a clear path for getting your Ruby application up and running on the JVM.
Bob McWhirter |
TorqueBox team lead at Red Hat |
Essential reading to learn not only how to deploy web applications on JRuby but also why.
David Calavera |
Creator of Trinidad |
Deploying with JRuby is a must-read for anyone interested in production JRuby deployments. The book walks through the major deployment strategies by providing easy-to-follow examples that help the reader take full advantage of the JRuby servers while avoiding the common pitfalls of migrating an application to JRuby.
Ben Browning |
TorqueBox developer at Red Hat |
Deploying with JRuby is an invaluable resource for anyone planning on using JRuby for web-based development. For those who have never used JRuby, Joe clearly presents its many advantages and few disadvantages in comparison to MRI.
Toby Crawley |
TorqueBox developer at Red Hat |
Within half an hour of picking up this book I found a solution to a deployment problem Ive had for months. Loaded with solid insight and relevant examples, this book is a must-have if youre looking for an approach to deployment that doesnt involve holding your breath.
Bryan Powell |
Founder of Metabahn, creator of Pakyow |
Acknowledgments
Its a remarkable feeling to have other people offer their time and energy to help improve a project that is your own creation. I have been fortunate enough to experience this feeling multiple times over the course of writing this book, so it is important that I try to thank the people who helped make it possible.
I must first thank the reviewers of my book who do not know me. I was shocked by the attention to detail and wise feedback they provided in making my book a finished product. Thank you to Jeff Holland, Matt Margolis, Stephen Wolff, Sam Rose, Tibor Simic, Frederico Tomassetti, Charley Stran, Ian Dees, Kevin Gisi, Wil Moore III, and the dozens of people who reported errata while this book was in beta. I consider you all to be my friends!
Thank you to my wonderful colleagues for their experience, wisdom, and editorial feedback as I worked on this project. They helped me in both the proposal process and the review process: Lyle Johnson, Matt Blackmon, Joshua Rufer, Bryan Powell, Bret Young, Matt Smith, and Robert Miller. This paragraph does not do our friendship justice. Thank you.
I would also like to thank the staff at the Pragmatic Bookshelf: Susannah Pfalzer, Dave Thomas, Andy Hunt, and probably a whole bunch of other people I dont know about. Above all, thank you to Brian P. Hogan, my editor. You have been fair and kind in dealing with much of the crude prose Ive thrown your way. Thank you for helping me with this book and to become a better writer.
It is also important that I thank the creators of the technologies I have written about. This book would not have been possible without their hard work. Thank you to Charles Nutter, Thomas Enebo, Nick Seiger, and the rest of the JRuby team. You are the most amazing group in all of the open source world. Thank you to David Calavera and Karol Bucek of the Trinidad project. Even during the holiday season, these brilliant programmers made themselves available to answer my questions. Thank you to Ben Browning, Toby Crawley, Bob McWhirter, Lance Ball, Jim Crossley, Marek Goldmann, and the rest of the TorqueBox team. Of this group, I must especially thank Ben and Toby, who also provided me with extremely insightful reviews. I hope that I have done justice to the effort these people have put into the technologies covered by this book. I owe them all my deepest gratitude and a free beverage.
Finally, I would like to thank my wife and son. I could not have completed this project without your love and support.
Copyright 2012, The Pragmatic Bookshelf.
Preface
Your website has just crashed, and youre losing money. The application is built on Rails, runs on MRI, and is served up with Mongrel and Apache. Having this kind of infrastructure means that youre managing more processes than you can count on two hands.
The background jobs are run with Resque, Its going to take some time to figure out which component is the culprit because you have no centralized management interface. Standing up a new server will take almost as long because the infrastructure is so complex. But the website has to get back online if you are going to stay in business.
The problem Ive just described is all too common. It has happened to everyone from small start-ups to large companies that use Rails to serve millions of requests. Their infrastructure is complex, and the myriad components are difficult to manage because they are heterogeneous and decentralized in nature. Even worse, Rubyists have become comfortable with this way of doing things, and many think it is the only way of doing things. But that is not the case.