Skip to content

Add PartitionSupervisor #11468

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

Merged
merged 7 commits into from
Dec 13, 2021
Merged

Add PartitionSupervisor #11468

merged 7 commits into from
Dec 13, 2021

Conversation

josevalim
Copy link
Member

@josevalim josevalim commented Dec 10, 2021

A supervisor with that starts multiple partitions of the same child.

Certain processes may become bottlenecks in large systems.
If those processes can have their state trivially partitioned,
in a way there is no dependency between them, then they can use
the PartitionSupervisor to create multiple isolated and
independent partitions.

Once the PartitionSupervisor starts, you can dispatch to its
children using {:via, PartitionSupervisor, {name, key}}, where
name is the name of the PartitionSupervisor and key is used
for routing.

@josevalim josevalim closed this Dec 10, 2021
@josevalim josevalim reopened this Dec 10, 2021
A supervisor with that starts multiple partitions of the same child.

Certain processes may become bottlenecks in large systems.
If those processes can have their state trivially partitioned,
in a way there is no dependency between them, then they can use
the `PartitionSupervisor` to create multiple isolated and
independent partitions.

Once the `PartitionSupervisor` starts, you can dispatch to its
children using `{:via, PartitionSupervisor, {name, key}}`, where
`name` is the name of the `PartitionSupervisor` and key is used
for routing.
Co-authored-by: Eric Meadows-Jönsson <eric.meadows.jonsson@gmail.com>
Co-authored-by: João Ângelo <angelojr10@gmail.com>
@josevalim josevalim marked this pull request as ready for review December 10, 2021 15:34

## Implementation notes

The `PartitionSupervisor` requires a name as an atom to be given on start,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit limiting, though it will probably suffice for most cases. I find it a bit disappointing that I can't start this from e.g. a child of a dynamic supervisor, or any other process which is started in unknown number of copies.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could make it generic by using a registry and storing the ETS table there. We would need to assemble the Registry dynamically though but that's not a problem. IIRC many OTP services get started on first use. it is doable and we can do it in the future. :)

Co-authored-by: Fernando Tapia Rico <fertapric@gmail.com>
Copy link
Member

@fertapric fertapric left a comment

Choose a reason for hiding this comment

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

😍

@josevalim josevalim merged commit 2ec501e into main Dec 13, 2021
@josevalim josevalim deleted the jv-ps branch December 13, 2021 14:07
@josevalim
Copy link
Member Author

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants