Bootstrapping
The fastest way to bootstrap Ruby on Rails

Summarized using AI

The fastest way to bootstrap Ruby on Rails

Uchio KONDO • April 18, 2019 • Fukuoka, Japan

In this presentation from RubyKaigi 2019, Uchio Kondo addresses the challenges of long bootstrap times in Ruby on Rails applications, particularly in complex or legacy systems. He emphasizes that slow bootstrapping can hinder efficient autoscaling in environments like Kubernetes. Kondo introduces a solution that involves utilizing a technology called CRIU (Checkpoint and Restore In Userspace), which allows developers to create process dumps that can significantly reduce the time required to start applications. Key points discussed in the presentation include:

  • Challenges with Bootstrap Times: Ruby on Rails applications, especially monolithic or legacy ones, often take excessive time to bootstrap.
  • Introduction of Bootsnap: Kondo mentions existing solutions like Bootsnap that can help improve boot times.
  • CRIU Overview: He explains CRIU as a tool that performs process dumps 'ahead of time', enabling faster boot from an image. In his case, he reduced boot time from 2,500ms to 1,200ms using this method.
  • Wide Applicability: CRIU is effective not just for Ruby on Rails, but also for other frameworks such as Hanami and scripting languages like Python and Node.js.
  • Efficiency in Migrations: Kondo outlines how CRIU helps in migrating applications efficiently without needing to restart containers, thereby preserving service availability during deployment.
  • Specific Examples: He highlights the slow startup time of Jenkins and how CRIU can mitigate such delays, demonstrating improved efficiency in migrating apps and enhancing overall performance.
  • Concluding Insights: Kondo concludes by underscoring CRIU's transformative potential for speeding up application boot processes, ultimately enhancing user experience and allowing developers to maintain focus on feature development without the burden of long deployment downtimes. He invites questions and engagement from the audience, indicating his openness to further discussion on using CRIU or Ruby on Rails solutions.

The fastest way to bootstrap Ruby on Rails
Uchio KONDO • April 18, 2019 • Fukuoka, Japan

Ruby on Rails applications sometimes take too long time in bootstrapping, especially when the application is complicated, monolithic or "legacy" one. This inhibits Kubernetes or other orchestrators to do smooth autoscaling. There are technologies such as bootsnap to solve this problem. In addition to them, I propose new strategy - "checkpoint and restore". I used CRIU(Checkpoint and Restore In Userspace) in Linux environment to make "ahead of time" process dump, and boot the application from image to reduce the bootstrap time. In my case, observed bootstrap time is reduced from about 2,500ms to 1,200ms. I will describe what the CRIU is in the first place, use cases where CRIU is effective and some problems using CRIU.

RubyKaigi 2019 https://rubykaigi.org/2019/presentations/udzura.html#apr19

RubyKaigi 2019

00:00:00.089 Hello, everyone! Thank you for coming.
00:00:06.710 I'm here to speak about something that affects Ruby on Rails applications.
00:00:14.290 Ruby on Rails applications sometimes take too long to bootstrap, especially when the application is complicated, monolithic, or legacy.
00:00:31.160 My name is Uchio Kondo, and I am one of the local organizers for RubyKaigi 2019.
00:00:45.660 I have written some books and contributed to open-source projects. I enjoy working with Ruby and its frameworks.
00:01:07.189 Currently, I live and work in Fukuoka at GMO Internet.
00:01:14.880 Please visit Fukuoka, the best coffee town!
00:01:22.280 I also assist in organizing events like Cocoa and Ruby conferences.
00:01:45.420 My presentation will focus on how to make Ruby on Rails applications bootstrap faster.
00:02:01.250 These solutions include using technologies like Bootsnap.
00:02:07.979 I will also introduce a new strategy called 'checkpoint and restore' that uses CRIU (Checkpoint and Restore In Userspace) in a Linux environment.
00:02:30.170 This approach allows for creating process dumps ahead of time.
00:02:37.079 By booting the application from an image, we can significantly reduce bootstrap times.
00:02:50.970 In my case, I observed that the bootstrap time was reduced from about 2,500 milliseconds to 1,200 milliseconds.
00:03:01.250 Let's first introduce CRIU.
00:03:07.769 CRIU is pronounced like 'crew' and I am a Dutch contributor to it. I've explored many parts of its code, which is mostly written in C language.
00:03:30.540 CRIU is particularly effective for various Ruby frameworks, including Ruby on Rails, Hanami, and many others. It’s also useful for scripting languages such as Python and Node.js.
00:03:58.019 CRIU enables us to perform various operations on the application processes efficiently.
00:04:46.530 This is a valuable tool for improving boot times and ensuring efficient application performance.
00:05:02.020 I will show examples of how CRIU can facilitate fast migrations of applications.
00:05:18.750 When rebooting, you may not want to restart your containers, especially for mission-critical applications.
00:05:29.650 Using CRIU, you can save the state of your containers without restarting them, thus reducing downtime and maintaining service availability.
00:05:55.419 I will discuss how this solution helps speed up app migrations and preserve application states.
00:06:07.769 By using CRIU, we can achieve quick migrations and fast boot times.
00:06:16.650 This is important particularly for applications with significant resource demands, as we want to avoid any unnecessary bottlenecks.
00:06:30.830 CRIU uses various technologies under the hood, and I'll outline its key functionalities in detail.
00:06:46.490 For example, it can help with the migration of apps efficiently so you can keep deployments running smoothly.
00:07:02.960 Next, I will describe a specific scenario with Ruby on Rails.
00:07:10.950 For instance, when using dynamic web applications, speed is key, and CRIU can facilitate this.
00:07:30.170 Using CRIU for Rails applications allows for optimizations that significantly improve boot times.
00:07:44.250 In testing, I found that applications such as Jenkins experience a delay when starting up due to their complexity.
00:08:00.090 Jenkins can take around five seconds to boot, which adds significant delay in service response.
00:08:20.430 This is where the use of CRIU to reduce this boot time becomes crucial, allowing you to bring services online more quickly.
00:08:32.260 When the necessary configurations are set, restoring an application with CRIU can happen almost instantaneously.
00:08:50.220 This means developers can focus on adding features without worrying about long downtimes during deployment.
00:09:10.700 Overall, the improvement in application delivery speed is noticeable, enhancing user experiences.
00:09:28.540 In conclusion, CRIU represents a transformative approach to managing application boot processes.
00:09:51.570 Thank you for your attention. I hope you find these insights helpful for your projects.
00:10:07.900 Are there any questions about using CRIU or Ruby on Rails?
00:10:19.000 I appreciate your interest and I look forward to any questions you might have.
Explore all talks recorded at RubyKaigi 2019
+73