Parallel Minion
Run slow steps at the same time and cut request latency. For Ruby and Rails.
Description
Parallel Minion allows you to take existing blocks of code and wrap them in a minion so that they can run asynchronously in a separate thread. The minion then passes back the result to the caller when or if requested. If any exceptions were thrown during the minion processing, it will be re-raised in the callers thread so that no additional work needs to be done when converting existing code to use minions.
Example
# Starts running immediately, on its own thread
minion = ParallelMinion::Minion.new(
product_id,
description: 'Inventory lookup',
timeout: 1_000
) do |id|
InventorySupplier.check(id)
end
# Do other work here, while the minion runs...
# Collect the result
inventory = minion.resultBecause the two run at the same time, the elapsed time is that of the slower one rather than the sum of both.
Documentation
For complete documentation see: https://minion.reidmorrison.com
- Guide, a step by step introduction
- Tuning, metrics and dashboards for dividing up the work
- Rails, executor, request context and ActiveRecord scopes
- Reference, every option and method
- Upgrading, moving from v1 to v2
For AI assistants: llms.txt (documentation index) and
llms-full.txt (complete documentation in one file).
The same pages are also included as markdown in the installed gem, under docs/.
When do minions help?
Minions help when code is waiting on something: a database query, an HTTP call, an external service. CRuby releases the GVL while a thread waits on I/O, so those waits genuinely overlap.
Minions do not speed up pure Ruby computation on CRuby, since that holds the GVL. JRuby and TruffleRuby have no GVL and do run such work in parallel.
Production Use
Parallel Minion is used in high performance, highly concurrent production environments running Ruby on Rails. Moving existing blocks of code into minions has produced significant reductions in request processing time, over 30% on one large application.
Installation
gem install parallel_minion
Compatibility
Ruby 3.2 or greater, tested against Ruby 3.2, 3.3, 3.4 and 4.0.
Rails is optional. When present, Rails 7.2, 8.0 and 8.1 are tested.
Meta
- Code:
git clone git://github.com/reidmorrison/parallel_minion.git - Home: https://github.com/reidmorrison/parallel_minion
- Bugs: http://github.com/reidmorrison/parallel_minion/issues
- Gems: https://rubygems.org/gems/parallel_minion
This project uses Semantic Versioning.
Author
Reid Morrison :: @reidmorrison
License
Copyright 2013-2026 Reid Morrison
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.