JRubyのパワーを解き放つ:パフォーマンスと多様性向上のためのRailsアプリ

Unlocking the Power of JRuby: Migrating Rails Apps for Enhanced Performance and Versatility

@ryudoawaru at Kaigi on Rails 2024, 2024/10/25

Hello everyone, today I want to talk about running JRuby on Rails and what does it mean for us Rails developers.

Who Am I?

  • Rubyist from 2007
  • CEO of 5xRuby.com
  • Evangelist of Ruby in Taiwan / 台湾のRuby伝道師
  • 日本では竜堂 終と呼ばれています
  • Chief Organizer of RubyConf Taiwan
  • I'm Mu-Fan Teng, but you can also call me Ryudo Owaru - my Japanese name.

    I've been working with Ruby for over 17 years.

    I'm a Ruby Evangelist in Taiwan and work in 5xRuby as CEO.

    Recent Ruby Community Activities in Taiwan

    RubyConf Taiwan

    COSCUP Ruby Community Room

    Monthly Ruby Jam Meetup

    Let me share some Ruby events in Taiwan.

    Last December, we had the first RubyConf Taiwan after the pandemic.

    This August, we had a Ruby Community Room at COSCUP 2024 which is a general OSS conference.

    We also have monthly meetup called Ruby Jam.

    These show how active our Ruby community is.

    You're all welcome to join us when you visiting Taiwan.

    Partnership With RubyCity Matsue
    ルビーシティ松江とのパートナーシップ

    Let me share our growing partnership with Ruby City Matsue. We've had three significant events over the past year.

    In November 2023, during Ruby World Conference, I visited Matsue City Hall to discuss Ruby community cooperation with Mayor うえさだ あきひと. The following month, we were honored to have Deputy Mayor やまね こうじ give a speech at RubyConf Taiwan 2023.

    On this March, Mayor うえさだ and his team visited 5xRuby. During this visit, we had productive discussions about future collaboration in three key areas: community exchange, business cooperation, and talent development.

    We're excited about step up the connection between our Ruby communities and look forward to more collaboration.

    Agenda

  • What's JRuby / JRubyとは
  • My journey with JRuby / JRubyとの出会い
  • Differences Between JRuby and CRuby / JRubyとCRubyの違い
  • How to migrate your Rails App from CRuby to JRuby / CRubyからJRubyへの移行方法
  • Benchmark for Rails Projects / Railsプロジェクトのベンチマーク
  • JRuby Ecosystem Status / JRubyエコシステムの現状
  • Conclusion / まとめ
  • Today's agenda will start with a brief introduction to JRuby, followed by sharing my experience with JRuby and explaining the differences between JRuby and CRuby.

    Next, I'll discuss my experience on how to migrate CRuby on Rails projects to JRuby, including potential challenges and solutions you might encounter during the process.

    Then, I'll share benchmark results from converting some of my projects to JRuby. These results will help us Rails engineers better understand the benefits of using JRuby in Rails projects and when it's appropriate to use.

    Finally, I'll briefly discuss the current state of the JRuby ecosystem based on my understanding over the past few months, followed by concluding remarks.

    What's JRuby

  • Ruby on the Java Virtual Machine(JVM)/ Java仮想マシン(JVM)上で動作するRuby
  • Most long-live Ruby implementation besides CRuby / CRuby以外で最も長い歴史を持つRuby実装
  • JRuby is one of many Ruby language implementations.

    It runs on the Java Virtual Machine

    JRuby Compiler Pipeline

    This picture show the compiler pipeline of JRuby, first parsing Ruby scripts into Ruby IR, then compiling them into Java Byte Code for JVM execution.

    My Journey of JRuby

  • No Java Experience At All / Javaの経験は全くありませんでした
  • Start to work with Aspose Word Java 11 years ago / 11年前、上司からWord文書を操作するためのJavaライブラリであるAsposeを Rails プロジェクトで使用するよう指示されたことがきっかけでした
  • I actually have no Java experience at all.

    My first real encounter with JRuby was 11 years ago, when my manager assigned me to use a paid Java Library called Aspose in a Rails project to manipulate Word files.

    RJB Approach

    def save_document(xml_data, xslt_data, output_format)
      temp_xml_fn = "#{Time.current.to_i}-#{rand(1000)}.xml"
      File.write(temp_xml_fn, compose_xslt(xslt_data, xml_data) )
      aspose_doc = Rjb::import('com.aspose.words.Document').new(temp_xml_fn)
      aspose_doc.save("output.#{output_format}")
    end

    Initially, I used the RJB RubyGem to access Java Libraries in Ruby.

    This snippet of code is for rendering Word or PDF document by the Aspose Java library with XML data.

    Going Further: Developing New Projects with JRuby

    # config/initializers/aspose.rb
    ::Aspose = Java::ComAsposeWords
    require File.join(Rails.root, '/vendor/lib/Aspose.Words.jdk16.jar')
    java_import('com.aspose.words.License')

    In subsequent projects, in order to use more complete features of Aspose, we decided to start new projects directly using JRuby.

    This code is for requiring jar file into Ruby when initialize Rails.

    From that period, I had no chance to use JRuby in work anymore.

    What's Different with CRuby?

    For Rails Developers like you & me

    For Rails developers like us, what are the practical differences between JRuby and CRuby in actual usage?

    Easy Installation

  • Install JDK / JDKをインストール
  • Extract the JRuby zip / JRubyのzipを解凍
  • No building required / ビルドが不要
  • No OpenSSL version issue / OpenSSLバージョンの問題なし
  • In terms of installation, unlike CRuby which needs to be compiled beforehand, we only need to install JDK first, then download the packaged files from the JRuby official website, extract it, and it can be executed directly.

    There are also no annoying OpenSSL version issues.

    Beneficial from both Ruby & Java Ecosystem

    RubyとJavaの両エコシステムの恩恵

    The most significant advantage of using JRuby is being able to benefit from both the Java and Ruby language ecosystems simultaneously.

    Example: Access Oracle for your Rails Project in CRuby

  • Download & Install Oracle Instant Client / Oracle Instant Clientをダウンロード
  • Install Ruby-OCI8 RubyGem / Ruby-OCI8 Gem インストール
  • Install activerecord-oracle_enhanced-adapter RubyGem
  • For example, if your CRuby project need to access Oracle database, you need to download the Oracle Instant Client corresponding to the operating system & hardware.

    Then download and install it, which can be troublesome for platforms w/o installation packages, especially a huge pain for running in container or CI usage.

    Then, when installing the ruby-oci8 gem, we need to point the location of Oracle Instant Client's library and header files.

    Access Oracle for your Rails Project in JRuby

  • Download & put JDBC jar file in JRUBY_HOME dir / Oracle JDBCドライバの jar ファイルをダウンロードしてlibディレクトリに配置する
  • activerecord-oracle_enhanced-adapter RubyGem should be runnable
  • Instead of the disturbing process of CRuby, in JRuby, all you need is just download and put the Oracle JDBC driver jar file into your lib directory, no need for both Instance Client and ruby-oci8 gem.

    Monkey patch a Java Class in JRuby

    JRubyでのJavaクラスのモンキーパッチ例

    Aspose::DocumentBuilder.class_eval do
      (1..9).each do |hx|
        define_method "write_h#{hx}".to_sym do |*args|
          style = eval("Aspose::StyleIdentifier::HEADING_#{hx}")
          get_paragraph_format.set_style_identifier(style)
          if block_given?
            yield
          else
            writeln args.first
          end
          get_paragraph_format.set_style_identifier Aspose::StyleIdentifier::NORMAL
        end
      end
    end

    The most highlight of JRuby is that we can treat Java class like Ruby class.

    For example, this code snippet injects original Java class Aspose::DocumentBuilder by adding methods to insert outline level text into Word document, just like a helper method in Rails.

    Almost Java methods in camelcase name can be accessible through underscore name.

    Native Thread

    time = Benchmark.realtime do
      threads = 4.times.map do
        Thread.new do
          100.times { (1..10000).reduce(:*) }
        end
      end
      threads.each(&:join)
    end
    puts "Total time: #{time.round(2)} seconds"
    jruby p.rb # Total time: 3.02 seconds
    ruby p.rb # Total time: 14.26 seconds

    Since JRuby runs on top of the JVM, it can get true parallelism from native Java thread.

    For example, in my MacBook Air, this simple program can run 4 times faster within JRuby compare to CRuby.

    Migrate exist CRuby on Rails project to JRuby / 既存CRubyプロジェクトのJRubyへの移行

    Reveal the advantage w/o much pain.

    Next, I'll share my experience on how to migrate existing CRuby projects to JRuby.

    It usually doesn't take much time, though you might need to modify some code, and there will be cases where migration isn't possible.

    Steps of Migrating Exist Rails Project.

  • Find JRuby version correspond to CRuby version / CRubyバージョンに対応するJRubyバージョンを見つける
  • Gemfile adjustment / Gemfileの調整
  • Handle RubyGems compability / RubyGems互換性の対応
  • Here are the steps for migrating your project.

    First, find the JRuby version that matches your CRuby project.

    Second, adjust the Gemfile to specify which RubyGems to use for specific platform.

    Then, if any RubyGems show incompatibility with JRuby, you'll need to identify and resolve these issues or find alternatives.

    Finding the Correct JRuby Version Corresponding to CRuby

  • JRuby 9.4 for 3.x CRuby / Ruby 3.x にJRuby 9.4
  • JRuby 9.3 for almost 2.x CRuby / ほとんどのRuby 2.x にJRuby 9.3
  • Let's talk about choosing the right JRuby version. It's quite simple - Ruby 3.0 is our reference point.

    If your project uses CRuby 3.0 or newer, go with JRuby 9.4.

    For older CRuby versions, use JRuby 9.3. Thanks to Ruby's backward compatibility, this matching rule works well.

    Adjusting the Gemfile / Gemfileの調整

    # Gemfile
    
    platform :ruby do
      gem 'pg', '~> 1.1'
    end
    
    platform :jruby do
      gem 'activerecord-jdbc-adapter', '~> 71.0'
      gem 'activerecord-jdbcpostgresql-adapter', '~> 71.0'
    end

    Based on the platform option provided by Bundler and RubyGems, we can easily provide different Rubygems combinations for CRuby and JRuby in the Gemfile.

    This could makes the project runnable under both CRuby and JRuby.

    RubyGem Compatibility / RubyGem互換性

    The biggest obstacle to migration / 移行における最大の障壁

    Handling RubyGem compatibility usually takes the most time during the migration process.

    Alternative for C-Binding Gems

    Case

    Solution

    Example

    The RubyGem has API level equivalent replacement / API互換の代替品がある

    Use the API equivalent gem / API互換のgemを使用

  • pg / mysql2 → activerecord-jdbcxxx-adapter
  • oj → json
  • The RubyGem has functionally satiable replacement / 機能的に満足できる代替品がある

    Use the replacement and change relative code /

  • debug → ruby-debug
  • redcarpet → kramdown
  • Since JRuby is based on Java, it basically cannot use any C-Binding Rubygems unless the Gem is built with FFI.

    So for those Gems, we need to find API-level or functional-level alternatives, which may involve code modifications.

    Wrap-Up RubyGems

  • Wrap the platform-specific executable binary files up / プラットフォーム固有の実行可能バイナリファイルをラップアップします
  • Build and Package individually / 個別にビルドとパッケージングを行います
  • Beyond C-Binding RubyGems, there are many wrap-up RubyGems that aren't compatible with JRuby.

    A common example is TailwindCSS-Rails, which packages platform-specific TailwindCSS standalone CLI individually.

    Mechanism Behind Wrap-Up in CRuby

    For example, when execute the Ruby script tailwindcss, the script does ask Gem::Platform class to provide OS and CPU information then return the correct path of the CLI standalone within the Gem folder.

    In JRuby

    bundle exec bin/rails tailwindcss:watch
    rails aborted!
    Tailwindcss::Commands::UnsupportedPlatformException: tailwindcss-rails does not support the universal-java platform
    Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation

    When running the same code in JRuby, it will only return "universal-java" regardless of your hardware.

    As a result, it cannot find the platform-specific executable and raises an exception.

    Make the Wrap-Up script to Find Correct Path

  • Prepare the binary executable yourself / バイナリ実行ファイルを自分で準備
  • Make the wrap-up script to point to it / ラップアップスクリプトがそれを指すように設定
  • TailwindCSS-Rails can point the CLI out through TAILWINDCSS_INSTALL_DIR env variable / TAILWINDCSS_INSTALL_DIR環境変数でCLIを指定可能
  • Or just monkey-patching the script / またはスクリプトを直接パッチすること
  • As far as the wrap-up script is Ruby code, you can prepare the binary executable and modify the script to make it work.

    Some Gem like TailwindCSS-Rails has specific environment variable to point this out.

    Missing GemSpec for JRuby

  • For RubyGems has different dependency, files list or code for JRuby & CRuby / JRubyとCRubyで異なる依存関係、ファイルリスト、コードを持つRubyGems
  • These Gem should package and upload separately / これらのGemは個別にパッケージ化してアップロードする必要がある
  • Example: Airbrake-Ruby
  • Another common issue with RubyGem compatibility stems from the GemSpec configuration.

    Some RubyGems require different setups for platforms which describe in their GemSpec, and these versions should be packaged and uploaded individually.

    However, Gem owners might not always be aware of this when publishing. In most cases, this can be resolved by pointing to the GitHub version of the Gem.

    If that's not possible, you might need to fork it to your own repository and make the necessary modifications.

    Real-World Benchmark

    Next, let's look at benchmarks from a Rails project perspective, testing data that closely reflects real-world scenarios.

    Projects to Benchmark

    Project

    Ruby / Rails / Database

    Other Stack

    Taiwanese Dictionary Site / 台湾語辞書サイト

    Ruby 3.2+Rails 7.1 + PostgreSQL

    good_job

    Clinic reservation SAAS service / 診療予約SaaSサービス

    Ruby 3.1+Rails 7.0 + PostgreSQL

    sidekiq + Redis

    From several Rails projects I've been involved in developing and maintaining,

    I selected these 2 modern projects as test targets. Let me introduce these test projects in detail.

    Project Introduction--Taiwanese Language Dictionary Site

  • https://tggl.naer.edu.tw/
  • Formal Name: Taiwanese Hokkien Corpora Search System / 台湾閩南語コーパス検索システム
  • Held by "National Academy for Educational Research"(国家教育研究院)
  • Dictionary for "Taiwanese Hokkien" / 台湾閩南語の辞書
  • Searching corpus, grammar points and textbook vocabulary by Kanji & Romaji (Taiwanese Romanization System) / 台湾語ローマ字表記システムによる語彙、文法、教科書用語の検索
  • The first project is a Taiwanese Dictionary Site. Taiwanese here refers to Hokkien, a dialect developed from Minnan language.

    While not an official language, it's widely used in Taiwan.

    This project is hosted by a Taiwanese government agency - the National Academy for Educational Research - and was developed by us.

    It's a website where users can search for Taiwanese Hokkien language dictionaries or textbook examples using kanji characters or romanized spelling.

    The relationship between Taiwanese romanization and Kanji characters is similar to the relationship between Japanese hiragana and kanji, though Taiwanese romanization combinations are much more complex than Japanese hiragana.

    Therefore, this website's main functionality focuses on various search capabilities, without features like user uploads, and all functions are accessible without login requirements.

    Project Introduction--Clinic reservation SAAS service

  • https://clinking.com.tw/
  • Formal Name: Clinking
  • Clinic reservation, Multi-Tenancy SAAS service / 診療予約のマルチテナント型SaaSサービス
  • The next project is a clinic appointment booking service called Clinking.

    It's a software as a service platform, provided in a multi-tenant format for different clinics to use.

    Benchmark Stack

    For establish the stack for behchmark.

    I set up separate Application Server, Database, and stress testing instances in the cloud, conducting tests within the internal network to eliminate network latency factors. During the testing process, I ensured that the database host's configuration and specifications would not become a bottleneck for application performance.

    The default setup uses 4 cores and 8GB RAM for the both Application and DB instance , and the Tester Instance has only 2GB RAM with 2 cores.

    Testing Method

  • Write custom K6 test script for each project / 各プロジェクト用のK6テストスクリプトを作成
  • Adjustable Parameters / 調整可能なパラメータ:
  • Virtual User / 仮想ユーザー数
  • Execution Duration / 実行時間
  • Max acceptable request duration / 最大許容リクエスト時間
  • To simulate real scenarios for testing, we specifically wrote custom K6 scripts for different projects.

    Additionally, we adjust Virtual Users and Execution Duration and set a maximum request threshold; requests exceeding this threshold are considered failed.

    Common Application Setup

    CRuby

  • Puma worker Mode
  • Worker count = CPU Core Count
  • 1 Worker with 4 threads
  • RUBY_OPTS="--yjit"
  • JRuby

  • Puma single mode
  • SET THREAD SIZE = Core x 4
  • JAVA_OPTS = "-Djruby.compile.invokedynamic"
  • JRuby has to do the "warm-up" phase first (usually takes 4 mins)
  • Whether it's JRuby or CRuby, we use Puma to run the service and Nginx as a Reverse Proxy.

    By default, for the CRuby group, we set to use Puma's Worker Mode, expecting the number of Workers to match the number of CPU cores, with each Worker opening 4 Threads, and enabling YJIT.

    For the JRuby group, we directly set the THREAD Size equal to sum of CRuby group and enable the JVM's invokedynamic option.

    However, due to the nature of JVM, we have to initiate a 4-minute warm-up run to ensure the JVM JIT compiler can run and optimized.

    Benchmark Script—Taiwanese Dictionary Site

  • Prepare 5 Taiwanese romanization terms in advance / 事前に5つの台湾語ローマ字表記の用語を準備
  • Each iteration:
  • Randomly select one term / ランダムに1つの用語を選択
  • Query the corpus database / コーパスデータベースに問い合わせ
  • Fetch results with 100 items per page / 1ページあたり100項目の結果を取得
  • Wait 0.5 seconds before next iteration / 次のイテレーションまで0.5秒待機
  • Keeps running iteration in 4 mins / 4分間イテレーションを継続実行
  • Test with 16 & 24 virtual users / 16名および24名の仮想ユーザーでテスト
  • For the dictionary project testing, we prepared five different Taiwanese romanization terms beforehand.

    In each test iteration, the script randomly selects one of these terms and queries the corpus database.

    The system then retrieves and displays the results, showing 100 items per page.

    Result:

    Item

    VUs

    CRuby

    JRuby

    Total Request

    16

    4806

    4928

    P95 Response Time

    16

    455

    417

    Total Request

    24

    6103

    6390

    P95 Response Time

    24

    709

    664

    Ram Usage

    1.6GB

    3GB

    From the test results, we can see that while JRuby currently achieves nearly 5% advantage in throughput, it also consumes almost twice the RAM.

    Benchmark Script—Reservation SAAS Service

  • Enter the clinic's homepage / 診療所のホームページに入る
  • Switch departments / 診療科を切り替える
  • Switch to next week / 次の週に切り替える
  • Rest for 0.5 seconds, then repeat the above behavior / 0.5秒休憩後、上記の動作を繰り返す
  • Keeps running iteration in 4 mins / 4分間イテレーションを継続実行
  • CPU intensive / CPU集中型の処理
  • For the appointment service project, we simulate a typical patient entering the homepage, browsing different departments and dates, resting for 0.5 seconds, then repeating.

    This is a backend heavy operation as it iterates through all time period and reservation slots for that department of the clinic for the week to check current reservation status.

    Additionally, for departments currently seeing patients, it displays the current patient number.

    Result:

    Item

    VUs

    CRuby

    JRuby

    Total Request

    8

    2730

    3090

    P95 Response Time

    8

    918

    729

    Total Request

    12

    3072

    3546

    P95 Response Time

    12

    1204

    1027

    Ram Usage

    0.8GB

    2.6GB

    Despite consuming more memory, JRuby achieves significantly meaningful performance improvements in this case.

    When the number of users increases, JRuby can outperform CRuby by 15 percent or more.

    On the other hand it also takes 3 times more ram then CRuby.

    Benchmark-Conclusion

  • For CPU-intensive workloads, JRuby can achieve higher throughput and lower request times with limited CPU resources under the same specifications / CPU集中型の処理において、JRubyは同じ仕様の限られたCPUリソースでより高いスループットと低いリクエスト時間を達成できます
  • JVM requires substantial RAM to run, which can be limited by adjusting GC and Heap Size parameters, but this will reduce performance / JVMの実行には相当量のRAMが必要で、GCとヒープサイズのパラメータ調整で制限可能ですが、性能は低下します
  • The more CPU cores a single instance has, the more obvious JRuby's parallelism advantage becomes / 単一インスタンスのCPUコア数が多いほど、JRubyのパラレリズムの利点がより顕著になります
  • A tipping point needs to be reached before JRuby's advantages become apparent / JRubyの利点が現れるまでには閾値に達する必要があります
  • Summarizing the above tests, we can understand that:

  • JRuby's current advantage lies in the Parallelism brought by Native Thread, provided there are enough CPU cores in the instance
  • Meanwhile, it consumes considerable RAM, although this can be adjusted through JAVA parameters for Garbage Collection and Heap Size, but this comes with CPU computational overhead
  • In conclusion, it needs to break through a threshold to show its strengths, and this threshold depends on your application type and hardware setup.
  • State of JRuby's Ecosystem

    For Rails Development

    Next I'll talk about the state of JRuby's ecosystem for Rails development.

    JRuby Core Development

  • RedHat stopped supporting JRuby development from Q3 this year / RedHatは今年第3四半期からJRuby開発のサポートを停止
  • The JRuby team still continuously keep developing new versions / 開発を続けている
  • Seems ver 10 will come by end of this year / バージョン10が今年末までにリリースされる予定
  • Currently, JRuby's core development is mainly carried out by Charles and Thomas and the JRuby 10 will come by end of the year.

    Even after RedHat stopped their support, development hasn't been interrupted, so it's safe to use at present.

    However, there are still some issues with key gems in the Rails ecosystem.

    activerecord-jdbc-adapter

  • Official release in RubyGems.org currently only supports up to Rails 7.0 (Ver 70.2) / RubyGems.orgの公式リリースは現在Rails 7.0(バージョン70.2)までのみ
  • Version for Rails 7.1 needs to be checked out from repository & built manually / Rails 7.1用のバージョンはリポジトリからチェックアウトして手動でビルドする必要がある
  • For us Rails developers, the most important active-record JDBC adapter doesn't yet officially support Rails 7.1 and 7.2, which is the most crucial issue to watch.

    The main branch in GitHub can be built and run with Rails 7.1 but still not officially released yet.

    activerecord-oracle_enhanced-adapter

  • The RubyGem.org version can not use in JRuby(GemSpec issue)/ RubyGem.orgのバージョンはJRubyで使用できません(GemSpec問題)
  • The source code in GitHub repo contains patch for legacy JRuby versions which is not compatible with 9.4 / GitHubリポジトリのソースコードには、9.4と互換性のない古いJRubyバージョン用のパッチが含まれています
  • Pull Request: https://github.com/rsim/oracle-enhanced/pull/2413
  • While the Oracle Enhanced Adapter works with JRuby, you cannot install it directly from RubyGems.org due to GemSpec dependency constraints.

    You'll need to install from its GitHub repository source code.

    However, when using recent JRuby versions, some legacy compatibility patches in the adapter's source code need to be removed.

    A pull request addressing this issue has been submitted, though the repository's GitHub Actions CI is currently experiencing issues.

    Other RubyGems

  • Lack of Gemspec is a common issue / Gemspecの不足は一般的な問題
  • Some infrastructure gems, like rbtree or debug, need Java versions to fully utilize JRuby's potential performance / rbtreeやdebugなどのインフラストラクチャgem群は、JRubyの潜在的なパフォーマンスを十分に活用するためにJavaバージョンが必要
  • Ref: https://github.com/ruby/debug/issues/1120
  • Many RubyGems are lack of proper Gemspec updated for JRuby, also there are some fundamental Gems like rbtree or debug need to have Java version implemented.

    Conclusion

    My Motivation

  • Explore: "What advantages does changing from CRuby to JRuby have on Rails?" / 探求:「CRubyからJRubyへの変更はRailsにどのような利点があるのか?」
  • Do something not related to work directly, conference Driven Development / 直接仕事に関係のないことをする、カンファレンス駆動開発
  • Beginning of doing some OSS contribution / OSSコントリビューションの始まり
  • About my motivation for this talk:

    For us Rails developers, while JRuby seems to have many benefits, the most important question is probably "Is it really as fast as it appears?"

    Having seen Charles discussing JRuby development and showing benchmarks in his presentations every year, as a Rails developer, I couldn't help but be very interested in exploring "What advantages can we take by JRuby on Rails?"

    I also want to do something not directly related to my work, and this could be a starting point for my OSS contributions beyond organizing community events.

    When Should Take JRuby into Account?

  • When you want to use specific Java Libraries like / 特定のJavaライブラリを使用したい場合:
  • Apache POI
  • When you want to increase total throughput under heavy loading conditions and accept increased RAM usage as a trade-off / 高負荷条件下で総スループットを増やしたい場合で、RAM使用量の増加をトレードオフとして受け入れられる場合
  • For projects with legacy versions of Ruby / 古いRubyを使用しているプロジェクトの場合
  • For Rails Projects, here are several scenarios where you might consider migrating your CRuby project to JRuby:

  • When you want to use Java-exclusive Libraries in Ruby - this is the ideal scenario, and you can enjoy Ruby's language features
  • In CPU-intensive and heavy load situations where you want to improve performance, though you'll need to accept significantly higher RAM usage as a trade-off
  • For projects with older CRuby versions before 3.0, you can get free performance improvement by using JRuby and avoid the annoying building issues.
  • The Future of "JRuby on Rails"

  • The main developers are continuously keeping up with CRuby's new features and versions / メイン開発者はCRubyの新機能とバージョンへの追従を継続的に維持しています
  • Both documentation and gems rely on Open Source = the power of the community / ドキュメントもgemもオープンソース = コミュニティの力に依存
  • A lot of RubyGems need maintenance for JRuby compatibility / 多くのRubyGemsがJRubyとの互換性のためのメンテナンスを必要としています
  • As for JRuby's future, as the most long-lived Ruby Implementation, it still depends on community member's effort to maintain the ecosystem.

    Besides the core and documentation, I think the most important effort is to maintain RubyGems for JRuby compatibility.

    How To Support JRuby?

    Donation @headius

    JRuby Consultantation

    JRuby Matrix

    If you want to support JRuby, there are following QR code links.

  • Donate Charles Nutter, who is main author of JRuby
  • Consider to consultant Charles if you are using JRuby in production
  • Join JRuby Matrix channel
  • ご清聴ありがとう ございました

    Special Thanks support from @headius

    Thank you all for listening.

    Also I want to thank to Charles advised me a lot for this slide.