Why Roda is one of the best alternatives to Ruby on Rails

Sep 8 | Henrique F. Teixeira

If you are a Ruby dev thinking about building a new project and looking for alternatives to Rails without leaving the language, consider the Roda framework.

Roda was created by Jeremy Evans, a Ruby core committer and one of the most influential developers in the community, and in my opinion, it is the most well-written framework considering the language's characteristics: it takes advantage of syntax and metaprogramming in an intelligent yet simple way while delivering productivity, extensibility, and more performance. These are the main advantages:

Performance

When Ruby was created by Yukihiro Matsumoto (known as "Matz") in 1993, the primary goal wasn't maximum performance, but rather to make software development more pleasant and efficient, which translates to:

  • Expressive and readable syntax.
  • Less code to solve problems.
  • Preference for productivity and maintainability over raw performance.

Today, more than 30 years later, we can say that Matz achieved (and continues to achieve) his goal, with strong adoption among high-growth startups, especially through Ruby on Rails.

However, in exchange for these benefits, the language brings a few important limitations:

  • CPU: Ruby is an interpreted, highly dynamic language. Methods can be redefined at runtime, classes can be modified at any time, and method call resolution happens in a more complex manner than in statically compiled languages. Modern Ruby's JIT (YJIT) has improved the scenario significantly, but Ruby still tends to be noticeably slower in CPU-intensive tasks.

  • Garbage Collector: Ruby uses a relatively advanced generational and incremental GC (Garbage Collector), but collection pauses can still impact latency. Applications with many object allocations can spend a considerable portion of their time running the GC instead of business logic.

  • Memory fragmentation: Even after the GC frees objects, the Ruby process doesn't always return this memory to the operating system efficiently. In long-running applications, it is common to observe gradual growth in memory consumption.

In summary, a Ruby system with many abstractions, allocated objects, and metaprogramming can end up costing more and requiring more hardware.

With that in mind, let's use the ObjectSpace class to identify how many objects we have, comparing Rails ("minimal" mode), Hanami, and Roda (I used roda-project to generate a fullstack Roda application with several plugins enabled).

For both applications, I added a /home/index route and a view with the following code:

<% @objects = ObjectSpace.count_objects %>
Total (slots): <%= @objects[:TOTAL]  %>
Free (free slots): <%= @objects[:FREE] %>
Objects (active objects): <%= @objects[:T_OBJECT] %>

I also sent a heavy load of requests to the endpoints using Apache Benchmark (ab), and for both I used Puma with 1 worker and 3 threads.

These were the results:

  • Rails (minimal): Total: 409268, Free: 47989, Objects: 25264
  • Hanami: Total: 346016, Free: 47648, Objects: 10682
  • Roda (with roda-project): Total: 239621, Free: 14515, Objects: 7661

In memory (verified with top -p), these allocated objects represented:

  • Rails (minimal): 222MB
  • Hanami: 139MB
  • Roda (with roda-project): 136MB

And here is the number of requests per second:

  • Roda (with roda-project): 939.89rqs
  • Hanami: 376.38rqs
  • Rails (minimal): 242.81rqs

Of course, this is a very simple benchmark; performance can vary drastically depending on the code we write and the problem we're solving. Furthermore, the database is usually the biggest performance offender in web applications, which generally have an I/O bound bottleneck.

But we can't deny one fact: Roda is what serves the most with the least when it comes to memory and performance, especially if we have a route focused on heavier processing (CPU bound), and much of this is due to its architecture and routing system:

  • Request evaluation stops at the exact moment the path matches its corresponding block.
  • Internal caching ensures minimal overhead (precompiled templates, lookup tables for static routes, app freezing).
  • No heavy metaprogramming: Many frameworks use method_missing or define methods dynamically at runtime, which degrades performance.

Check out the benchmarks on techempower.com as well, where Roda consistently ranks among the top-performing frameworks in the Ruby ecosystem.

Plugins / Extensibility

Roda was designed around an extremely simple and predictable plugin system.

Unlike other frameworks that expose dozens of extension points scattered across callbacks, middleware, generators, and conventions, Roda concentrates practically all of its extensibility into plugins that explicitly modify the application class.

When we write:

class App < Roda
  plugin :render
  plugin :json
  plugin :all_verbs
end

Each plugin adds methods, behavior, or features directly to the application. There is no hidden magic. You can trace exactly where each functionality came from.

Another important aspect is that Roda's core is extremely small. Routing—the framework's main responsibility—remains separated from additional features. This allows features such as rendering, authentication, sessions, caching, CSRF, JSON, and others to be implemented as independent plugins without increasing core complexity, while also ensuring our application doesn't waste resources on features we won't use.

Finally, Roda's plugin system is used by the framework itself. Many features considered "native" are implemented in the exact same way as plugins created by users. This is the sign of an extensible architecture: the mechanisms used internally are the same ones available to application developers.

See how simple it is to create plugins for Roda by following the steps described in the repository: github.com/jeremyevans/roda#label-Plugins

Productivity

Despite being an apparently "small" framework, when analyzing the amount of native plugins and plugins provided by the community, we have enough resources available to make it similar to Rails in features and build any type of application.

There are more than 100 official plugins listed in the official documentation, including essentials like:

  • CSRF
  • Sessions and Cookies
  • I18n
  • Views / Rendering
  • Hooks
  • Logs
  • Email delivery

Furthermore, among the alternatives to Rails, Roda is the only framework that has its own robust authentication gem. The rodauth gem adds an extremely complete and secure authentication system to our app, packed with features such as:

  • Account management
  • Password recovery
  • JWT
  • SMS codes / Recovery codes
  • Passwordless Authentication

To make creating and developing new applications easier, we have the roda-project gem, which provides a modern scaffold for Roda applications, including generators and several essential tasks, bringing the development experience close to Rails.

It's also worth highlighting that the entire Ruby gem ecosystem is at our disposal for whatever we need, including sidekiq, dry-rb, rom, async, etc.

Maturity

Roda has been around for over 10 years and has more than 20 million downloads, and major projects currently use the framework in production, notably Ubicloud. In addition, Jeremy Evans's work is well known for his zero-tolerance policy for bugs and fast responses on GitHub. Bug fixes and security releases typically arrive in extremely short timeframes, ensuring a dependable codebase.

Conclusion

If you're looking for architectural flexibility without losing productivity and tooling, or if you need an API / web application with a stronger focus on processing, Roda is worth using.

A few other cool links to dig deeper:

Hey, what did you think of this article??

Share and give your opinion by clicking on one of the networks below:


Thank you very much!