Skip to content

Commit

Permalink
Update 'clustered mode' references to 'cluster mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuay03 committed Feb 3, 2025
1 parent edd2a17 commit 57ee073
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
10 changes: 5 additions & 5 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

* Features
* Ability to supply a custom logger ([#2770], [#2511])
* Warn when clustered-only hooks are defined in single mode ([#3089])
* Warn when cluster mode-only hooks are defined in single mode ([#3089])
* Adds the on_booted event ([#2709])

* Bugfixes
Expand Down Expand Up @@ -733,7 +733,7 @@ Each patchlevel release contains a separate security fix. We recommend simply up
* Fix Java 8 support ([#1773])
* Fix error `uninitialized constant Puma::Cluster` ([#1731])
* Fix `not_token` being able to be set to true ([#1803])
* Fix "Hang on SIGTERM with ruby 2.6 in clustered mode" (PR [#1741], [#1674], [#1720], [#1730], [#1755])
* Fix "Hang on SIGTERM with ruby 2.6 in cluster mode" (PR [#1741], [#1674], [#1720], [#1730], [#1755])

## 3.12.1 / 2019-03-19

Expand Down Expand Up @@ -1144,7 +1144,7 @@ Each patchlevel release contains a separate security fix. We recommend simply up
* 4 minor features:

* Listen to unix socket with provided backlog if any
* Improves the clustered stats to report worker stats
* Improves the cluster mode stats to report worker stats
* Pass the env to the lowlevel_error handler. Fixes [#854]
* Treat path-like hosts as unix sockets. Fixes [#824]

Expand All @@ -1171,7 +1171,7 @@ Each patchlevel release contains a separate security fix. We recommend simply up
* Merge pull request [#884] from uistudio/async-callback
* Merge pull request [#888] from mlarraz/tick_minitest
* Merge pull request [#890] from todd/directory_docs
* Merge pull request [#891] from ctaintor/improve_clustered_status
* Merge pull request [#891] from ctaintor/improve_cluster_mode_stats
* Merge pull request [#893] from spastorino/add_missing_require
* Merge pull request [#897] from zendesk/master
* Merge pull request [#899] from kch/kch-readme-fixes
Expand Down Expand Up @@ -1871,7 +1871,7 @@ The "clearly I don't have enough tests for the config" release.

* 3 doc changes:
* Add note about on_worker_boot hook
* Add some documentation for Clustered mode
* Add some documentation for Cluster mode
* Added quotes to /etc/puma.conf

## 2.0.1 / 2013-04-30
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ Puma will automatically scale the number of threads, from the minimum until it c

Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So, even if you specify -t 1:1, expect around 7 threads created in your application.

### Clustered mode
### Cluster mode

Puma also offers "clustered mode". Clustered mode `fork`s workers from a master process. Each child process still has its own thread pool. You can tune the number of workers with the `-w` (or `--workers`) flag:
Puma also offers "cluster mode". Cluster mode `fork`s workers from a master process. Each child process still has its own thread pool. You can tune the number of workers with the `-w` (or `--workers`) flag:

```
$ puma -t 8:32 -w 3
Expand All @@ -116,13 +116,13 @@ Or with the `WEB_CONCURRENCY` environment variable:
$ WEB_CONCURRENCY=3 puma -t 8:32
```

Note that threads are still used in clustered mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total, with 16 in each worker process.
Note that threads are still used in cluster mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total, with 16 in each worker process.

If the `WEB_CONCURRENCY` environment variable is set to `"auto"` and the `concurrent-ruby` gem is available in your application, Puma will set the worker process count to the result of [available processors](https://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent.html#available_processor_count-class_method).

For an in-depth discussion of the tradeoffs of thread and process count settings, [see our docs](https://github.com/puma/puma/blob/9282a8efa5a0c48e39c60d22ca70051a25df9f55/docs/kubernetes.md#workers-per-pod-and-other-config-issues).

In clustered mode, Puma can "preload" your application. This loads all the application code *prior* to forking. Preloading reduces total memory usage of your application via an operating system feature called [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write).
In cluster mode, Puma can "preload" your application. This loads all the application code *prior* to forking. Preloading reduces total memory usage of your application via an operating system feature called [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write).

If the `WEB_CONCURRENCY` environment variable is set to a value > 1 (and `--prune-bundler` has not been specified), preloading will be enabled by default. Otherwise, you can use the `--preload` flag from the command line:

Expand All @@ -140,9 +140,9 @@ preload_app!

Preloading can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preloading copies the code of master into the workers.

#### Clustered mode hooks
#### Cluster mode hooks

When using clustered mode, Puma's configuration DSL provides `before_fork` and `on_worker_boot`
When using cluster mode, Puma's configuration DSL provides `before_fork` and `on_worker_boot`
hooks to run code when the master process forks and child workers are booted respectively.

It is recommended to use these hooks with `preload_app!`, otherwise constants loaded by your
Expand Down Expand Up @@ -176,7 +176,7 @@ after_refork do
end
```

Importantly, note the following considerations when Ruby forks a child process:
Importantly, note the following considerations when Ruby forks a child process:

1. File descriptors such as network sockets **are** copied from the parent to the forked
child process. Dual-use of the same sockets by parent and child will result in I/O conflicts
Expand Down
2 changes: 1 addition & 1 deletion docs/systemd.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ systemd and Puma also support socket activation, where systemd opens the
listening socket(s) in advance and provides them to the Puma master process on
startup. Among other advantages, this keeps listening sockets open across puma
restarts and achieves graceful restarts, including when upgraded Puma, and is
compatible with both clustered mode and application preload.
compatible with both cluster mode and application preload.

**Note:** Any wrapper scripts which `exec`, or other indirections in `ExecStart`
may result in activated socket file descriptors being closed before reaching the
Expand Down
4 changes: 2 additions & 2 deletions lib/puma/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ def after_worker_fork(&block)

alias_method :after_worker_boot, :after_worker_fork

# Code to run after puma is booted (works for both: single and clustered)
# Code to run after puma is booted (works for both single and cluster mode).
#
# @example
# on_booted do
Expand All @@ -822,7 +822,7 @@ def on_booted(&block)
@config.options[:events].on_booted(&block)
end

# Code to run after puma is stopped (works for both: single and clustered)
# Code to run after puma is stopped (works for both single and cluster mode).
#
# @example
# on_stopped do
Expand Down
3 changes: 1 addition & 2 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
Thread.abort_on_exception = true

$debugging_info = []
$debugging_hold = false # needed for TestCLI#test_control_clustered
$debugging_hold = false
$test_case_timeout = ENV.fetch("TEST_CASE_TIMEOUT") do
RUBY_ENGINE == "ruby" ? 45 : 60
end.to_i
Expand Down Expand Up @@ -265,7 +265,6 @@ def full_name
end

Minitest.after_run do
# needed for TestCLI#test_control_clustered
if !$debugging_hold && ENV['PUMA_TEST_DEBUG']
$debugging_info.sort!
out = $debugging_info.join.strip
Expand Down

0 comments on commit 57ee073

Please sign in to comment.