Need help with mod_mruby?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

198 Stars 30 Forks 1.0K Commits 6 Opened issues


mod_mruby: A Fast and Memory-Efficient Apache httpd Extension Mechanism Scripting with mruby

Services available


Need anything else?

Contributors list


mod_mruby: A Fast and Memory-Efficient Apache httpd Extension Mechanism Scripting with mruby.


ngx_mruby mod_mruby performance

hello world simple benchmark, see details of blog entry.

What's mod_mruby

mod_murby is A Fast and Memory-Efficient Web Server Extension Mechanism Using Scripting Language mruby for Apache httpd.

  • Unified Ruby Code between Apache(modmruby), nginx(ngxmruby) and other Web server software(plan) for Web server extensions.
  • You can implement Apache modules by Ruby on Apache httpd.
  • You can implement some Web server software extensions by same Ruby code (as possible)
  • modmruby is to provide an alternative to modlua or ngx_mruby of nginx.
  • Supported Apache Version: 2.2 2.4
  • Supported Apache MPM: worker prefork event
  • Supported OS: Linux FreeBSD Windows and so on.
# Apache httpd.conf
# mrubyTranslateNameMiddle "/path/to/proxy.rb"

backends = [ "", "", "", "", ]

write balancing algorithm here.

r =

r.handler = "proxy-server" r.proxyreq = Apache::PROXYREQ_REVERSE r.filename = "proxy:" + backends[rand(backends.length)] + r.uri


  • see example
  • Sample of Unified Ruby Code between Apache(modmruby) and nginx(ngxmruby) for Web server extensions
  • You can implement some Web server software extensions by same Ruby code (as possible)
# Unified Ruby Code between Apache(mod_mruby) and nginx(ngx_mruby)
# for Web server extensions.
# Apache httpd.conf by mod_mruby
#     mrubyHandlerMiddle "/path/to/unified_hello.rb"
# nginx ngxin.conf by ngx_mruby
# location /mruby {
#     mruby_content_handler "/path/to/unified_hello.rb";
# }

Server = get_server_class

Server::rputs "Hello #{Server::module_name}/#{Server::module_version} world!"

mod_mruby => "Hello mod_mruby/0.9.3 world!"

ngx_mruby => "Hello ngx_mruby/0.0.1 world!"


As the increase of large-scale and complex Web services, not only a development of Web applications but also an implementation of Web server extensions is required in many cases. The Web server extensions were mainly implemented in C language because of fast and memory-efficient behavior, but extension methods using scripting language are proposed with consideration of maintainability and productivity. However, if the existing methods primarily intended to enhance not the implementation of Web applications but the implementation of internal processing of the Web server, the problem remains in terms of fast, memory-efficiency and safety. Therefore, we propose a fast and memory-efficient Web server extension mechanism using scripting language. We design the architecture that a server process create the region to save the state of the interpreter at the server process startup, and multiple scripts share the region in order to process fast when the script is called as internal processing from a Web server process. The server process free the global variables table, the exception flag and the byte-code which cause the increase of memory usage mainly, in order to reduce the memory usage and extend safely by preventing interference between each scripts because of sharing the region. We implement the mechanism that can extend the internal processing of Apache easily by Ruby scripts using Apache and embeddable scripting language mruby. It's called "mod_mruby".


under the MIT License:


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.