-
Notifications
You must be signed in to change notification settings - Fork 128
Separate Registry pool size configuration #198
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
Separate Registry pool size configuration #198
Conversation
I believe it was to deal with the cases of very uneven distributions (also known as the Justin Bieber effect), where one topic could have million of entries more than others. I think we can go ahead with this, perhaps call the option |
Got it, I think it makes perfect sense when the
Cool, will rename. |
Hi again @josevalim. Do you think it would be reasonable to add an option to |
At first I don't see an issue with that, we can give it a try. :) |
💚 💙 💜 💛 ❤️ |
Cool, I can prepare something the week after next. |
Under our workload (a few thousand topics, single digit to a few thousand subscribers each, a few thousand broadcasts per second from a single node in the cluster), we have started to experience instability of the
PG2Worker
processes (arrival rate > processing rate => message queue growing indefinitely).We initially approached it by increasing the pool size, but this didn't help much.
After some investigation, we found that introducing more parallelism in processing incoming messages didn't help much because the PG2 worker processes did more work than before.
That's because
Registry
for:duplicate
keys is sharded by pids, not by key (topic). So, to get all the subscribers, we need to go through all the partitions and get the topic subscribers from each of them.Moreover, since the dispatch code is executed in the context of the worker process, the serialization cache is valid for just a single dispatch call.
Even if we fastlane serialization, we might execute it up to the number of partitions.
This PR allows configuring the
Registry
pool size to a value different from the PubSub pool size.Under our workload, I got the best results with removing the
Registry
pool entirely, i.e., settingregistry_pool_size: 1
.I'm happy to describe the new option in the documentation, but I'm wondering if there was a particular reason why the
:duplicate
registries are sharded by pids, not by keys. Perhaps that was done to remove contention on the ETS table for topics with many subscribers? Depending on the use case, I can see that picking a sharding method could be aRegistry
configuration option.