Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jhgg
Copy link
Contributor

@jhgg jhgg commented Feb 4, 2018

this is just a PoC to the sharding strategy. The idea is to register 4 partitioners with a preset of names, and then send to the correct partitioner in Manifold.send based off the pid of what is sending.

TODO:

  • compile time partitioner name generator.
  • application config for # partitioners
  • application config for # workers per partitioner.
  • way to pin a given process by some key to a specific partitioner as it changes pids (our handoff case)

@jhgg jhgg requested a review from vishnevskiy February 4, 2018 04:46
lib/manifold.ex Outdated
partitioner(:erlang.phash2(pid, 4))
end

defp partitioner(0), do: Manifold.Partitioner
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be compile time generated. but i dont want to pull out the ol' macro handbook.

Copy link
Contributor

Choose a reason for hiding this comment

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

When you add a macro its worth commenting why the first one has no number suffix. (backwards compat)

Choose a reason for hiding this comment

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

This would be a pretty simple macro. What precisely do you want it to generate?

lib/manifold.ex Outdated
end

def partitioner_for(pid) do
partitioner(:erlang.phash2(pid, 4))
Copy link
Contributor Author

@jhgg jhgg Feb 4, 2018

Choose a reason for hiding this comment

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

any reference of 3, or 4, should be a config.

@jhgg jhgg removed the request for review from vishnevskiy February 4, 2018 04:48
@jhgg jhgg mentioned this pull request Feb 4, 2018
7 tasks
@jhgg jhgg force-pushed the feature/sharded-partitioner branch 2 times, most recently from e096654 to 3c27b68 Compare February 6, 2018 03:14
@jhgg jhgg changed the base branch from feature/faster-partitioner to master February 6, 2018 03:14
@jhgg jhgg requested a review from vishnevskiy February 6, 2018 03:15
@jhgg jhgg force-pushed the feature/sharded-partitioner branch from 3c27b68 to 8ed150d Compare February 6, 2018 03:24
lib/manifold.ex Outdated
def send(nil, _message), do: :ok

def current_partitioner() do
partitioner_for(self())
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we think this can ever have a situation where during a handoff stuff starts being sent to another partitioner out of order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, there is no linearization requirement for handoffs across processes 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure?

If a manifold is backed up on a server.. then there is a handoff on another service which changes the current pid.. you might send things to a new partitioner on the backed up server, causing messages to arrive out of order?

@jhgg
Copy link
Contributor Author

jhgg commented Feb 6, 2018

@vishnevskiy see f192229 for what we discussed in DM.

@jhgg jhgg requested a review from vishnevskiy February 6, 2018 04:39
@jhgg jhgg merged commit 2ff1d6c into master Feb 6, 2018
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.

3 participants