Skip to content

Commit

Permalink
fork_worker does not work with preload_app! (#2468)
Browse files Browse the repository at this point in the history
Related to #2466
Close #2467

[ci skip]
  • Loading branch information
dentarg committed Oct 29, 2020
1 parent 61c6213 commit f0dffd4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions 5.0-Upgrade.md
@@ -1,6 +1,6 @@
# Welcome to Puma 5: Spoony Bard.

![https://i1.kym-cdn.com/entries/icons/original/000/006/385/Spoony_Bard.jpg](https://i1.kym-cdn.com/entries/icons/original/000/006/385/Spoony_Bard.jpg)
![https://i1.kym-cdn.com/entries/icons/original/000/006/385/Spoony_Bard.jpg](https://i1.kym-cdn.com/entries/icons/original/000/006/385/Spoony_Bard.jpg)

>Note: Puma 5 now automatically uses `WEB_CONCURRENCY` env var if set see [this post for an explanation](https://github.com/puma/puma/issues/2393#issuecomment-702352208). If your memory use goes up after upgrading to Puma 5 it indicates you're now running with multiple workers (processes). You can decrease memory use by tuning this number to be lower.
Expand Down Expand Up @@ -34,9 +34,9 @@ Users of this option should see reduced request queue latency and possibly less

Add the following to your `puma.rb` to try it:

```ruby
```ruby
wait_for_less_busy_worker
# or
# or
wait_for_less_busy_worker 0.001
```

Expand All @@ -52,7 +52,7 @@ Production testing at GitLab suggests values between `0.001` and `0.010` are bes

To use it, you can add this to your `puma.rb`:

```ruby
```ruby
nakayoshi_fork
```

Expand All @@ -68,7 +68,7 @@ Puma 5 introduces an experimental new cluster-mode configuration option, `fork_w
10004 \_ puma: cluster worker 3: 10000 [puma]
```

This allows the usage of `preload` with `phased_restart`. It also may improve memory usage because the worker process loads additional code after processing requests.
It is compatible with phased restarts. It also may improve memory usage because the worker process loads additional code after processing requests.

To learn more about using `refork` and `fork_worker`, see [the documentation](https://github.com/puma/puma/blob/master/docs/fork_worker.md).

Expand Down
2 changes: 2 additions & 0 deletions docs/fork_worker.md
Expand Up @@ -24,6 +24,8 @@ Similar to the `preload_app!` option, the `fork_worker` option allows your appli

### Limitations

- Not compatible with the `preload_app!` option

- This mode is still very experimental so there may be bugs or edge-cases, particularly around expected behavior of existing hooks. Please open a [bug report](https://github.com/puma/puma/issues/new?template=bug_report.md) if you encounter any issues.

- In order to fork new workers cleanly, worker 0 shuts down its server and stops serving requests so there are no open file descriptors or other kinds of shared global state between processes, and to maximize copy-on-write efficiency across the newly-forked workers. This may temporarily reduce total capacity of the cluster during a phased restart / refork.
Expand Down

0 comments on commit f0dffd4

Please sign in to comment.