Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Unicorn with Puma #8392

Merged
merged 3 commits into from Sep 10, 2022
Merged

Conversation

denschub
Copy link
Member

@denschub denschub commented Sep 7, 2022

This PR primarily replaces Unicorn with Puma. Unicorn has been unmaintained for quite some time, and on the other hand, Puma has been in production on at least Geraspora and Nerdpol for quite some time.

For podmins that still run the default setup, this will probably result in a significant reduction in memory usage, as Puma is a lot more efficient. (It also doesn't need to be killed regularly...) Unfortunately, this change means some breaking config changes, but oh well. I have included a Changelog entry, so you don't need to come up with something during the merge.

This PR also contains one commit that removes traces of a 12+ years old attempt at creating some federation integration testing, and it updates all binstubs.

Newly generated binstubs will check for the string
`This file was generated by Bundler` inside `bin/bundle`, so we'd have
to update that anyway.

Also, there is a non-zero chance the updated `bundle` binstub resolves
some of the setup-specific issues we've seen.
It's… safe to assume that nobody is using this, as this has been broken
for quite some time.
@denschub denschub added this to the 1.0.0 milestone Sep 7, 2022
Copy link
Member

@SuperTux88 SuperTux88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two little things.

Also, as podmins shouldn't change web_workers anymore, I was also wondering if we should add a config option to set the maximum number of threads, or if the default (5) is fine for all pod sizes? Or for really big pods would that still be the point where they would increase the workers if they need more than 5 threads?

config/defaults.yml Show resolved Hide resolved
config/eye.rb Outdated Show resolved Hide resolved
@denschub
Copy link
Member Author

denschub commented Sep 9, 2022

Review feedback addressed in the force push.

I was also wondering if we should add a config option to set the maximum number of threads, or if the default (5) is fine for all pod sizes? Or for really big pods would that still be the point where they would increase the workers if they need more than 5 threads?

So... I don't think so. Puma will auto-scale its thread pool with a default range of 0:5. Pods with spikes in traffic will see an increase in memory usage, that might result in funky square-wave memory curves, like that one:

Screenshot 2022-09-09 at 04 13 24

There, I had a bit of a (self-induced) load spike, and Puma kept the extra threads around for more than a day, just in case, before eventually releasing it again.

I don't think that the maximum of 5 is a problem. Puma will not scale up if the memory pressure is high, so there should not be ever a case where we're risking OOM. Large pods with lots of requests will see higher memory usage than smaller pods, but that's expected. Likewise, I don't think podmins will ever need more than 5 threads. I've never seen Geraspora exceed three threads, and I'm fairly sure that a pod would be completely on fire because of database latency before Puma scaling becomes a problem.

So, I don't think we need to make threads configurable. And, writing that, I realize I might just have made a case for removing the workers pref altogether - I don't think there is ever a case where a podmin would need more than one worker. And if a podmin does, then they're able to change the Puma config directly.

@SuperTux88
Copy link
Member

And, writing that, I realize I might just have made a case for removing the workers pref altogether - I don't think there is ever a case where a podmin would need more than one worker. And if a podmin does, then they're able to change the Puma config directly.

Yes, I think we should remove the web_workers setting then. And podmins can also set the max threads by setting a MAX_THREADS env var without editing the config, and if that then really isn't enough anymore, then yes, I think they can change the puma config themselves.

… and drop the single_process_mode. See the included Changelog entry
for full details on what this change means.
@denschub
Copy link
Member Author

denschub commented Sep 9, 2022

Setting removed - and Changelog changed accordingly - in another force-push.

@denschub
Copy link
Member Author

denschub commented Sep 9, 2022

(Note to bystanders: rspec tests are unhappy in this PR. But that's not my fault. It's September 9th, which means the profile that's used to verify that the Birthday Notification System isn't spamming everyone, ... has its birthday today...)

Copy link
Member

@SuperTux88 SuperTux88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now 🍪 and I'm just ignoring the broken tests now ;)

@SuperTux88 SuperTux88 merged commit ae4cbb1 into diaspora:develop Sep 10, 2022
@denschub denschub deleted the unicorn-dust branch September 10, 2022 00:12
@SuperTux88
Copy link
Member

Thanks for the finding with the binstubs, who knew that they needed to be re-generated, this isn't documented in the upgrade guide. But as this fixes the bundler issue a few podmins faced (verified locally), I backported it as 9075dfa and released it as 0.7.18.1. 🍪

SuperTux88 added a commit to SuperTux88/diaspora that referenced this pull request Sep 19, 2022
With diaspora#8392 the `single_process_mode` was removed, which means that
development now also requires a redis.
SuperTux88 added a commit to SuperTux88/diaspora that referenced this pull request Sep 19, 2022
When puma was introduced in diaspora#8392 the default listen configuration was
set to only localhost, which makes sense for most development setups,
but when run within docker, it needs to listen on all IPs so the port
can be forwarded to be accessable outside of docker.

Because the new default makes sense without docker, I overwrite the
option with a environment variable only in the docker-setup. This also
ensures that it always contains the right value needed for the
docker-setup to work, no matter what was configured outside of docker.
SuperTux88 added a commit to SuperTux88/diaspora that referenced this pull request Sep 19, 2022
With diaspora#8392 the `single_process_mode` was removed, which means that
development now also requires a redis.
SuperTux88 added a commit to SuperTux88/diaspora that referenced this pull request Sep 19, 2022
When puma was introduced in diaspora#8392 the default listen configuration was
set to only localhost, which makes sense for most development setups,
but when run within docker, it needs to listen on all IPs so the port
can be forwarded to be accessable outside of docker.

Because the new default makes sense without docker, I overwrite the
option with a environment variable only in the docker-setup. This also
ensures that it always contains the right value needed for the
docker-setup to work, no matter what was configured outside of docker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants