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

Sharding support #166

Open
19 of 31 tasks
c9s opened this issue Jan 18, 2017 · 0 comments
Open
19 of 31 tasks

Sharding support #166

c9s opened this issue Jan 18, 2017 · 0 comments

Comments

@c9s
Copy link
Member

c9s commented Jan 18, 2017

Shard Operations

  • Allocate Shard

  • Remove Shard

  • CloneShard (use mysqldbcopy)

    • Convert DSN into command string

      mysqldbcopy --source=user:pass@host:port:socket --destination=user:pass@host:port:socket orig_db:new_db
      
      mysqldbcopy --source=root@localhost:/opt/local/var/run/mysql56/mysqld.sock \
                  --destination=root@localhost:/opt/local/var/run/mysql56/mysqld.sock \
                  shade_src:shade_dst
      
  • Prune Shard

    • Iterate schemas
    • Prune collection with the sharding key.
      • Get the shard key
      • Query distinct values from collection.
      • Calculate shard Id on each value.
      • For each value, remove the rows that don't belong to the shard.
  • Move Chunk

    • Provide import method in Repository

      $repo->import($book);
      
      When importing a record into different repo, we should remove the auto-increment key.
      
      $repo->duplicate($book);
      
      When duplicating a record, all the details of the record should be the same in the new repository.
      
    • Provide moveTo method in BaseModel

      $book->moveTo($repo2);
      
    • Move a shard to another instance.

  • Reshard

  • Split Chunk

    • Implement a consistent hash
    • Add target by pre-computed index.
    • Implement ChunkManager to initialize a chunk list with specific range.

Aggregation Query

  • BroadcastQuery
    • Broadcast SQL statement to all shards.
  • Extract SQL building method for create (insertion)
  • Extract SQL building method for update
  • Extract SQL building method for delete
  • Map SQL and arguments to QueryWorker and then reduce the result...
  • QueryDispatcher
    • Given a query, return Repo objects with different connections and
      run queries on these nodes.

    • Shard by Range

    • Virtual Shards (by using larger key space)

Instance Management Commands

  • instance add
  • instance remove
@c9s c9s added the shard label Apr 5, 2017
@c9s c9s added this to the 4.0 Release milestone Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant