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

Feature(strategy): support mysql read_write_splitting #88

Closed
9 tasks done
xuanyuan300 opened this issue Jun 13, 2022 · 1 comment · Fixed by #97
Closed
9 tasks done

Feature(strategy): support mysql read_write_splitting #88

xuanyuan300 opened this issue Jun 13, 2022 · 1 comment · Fixed by #97
Assignees
Labels
app:pisa-proxy Pisa-Proxy related changes in:strategy Strategy related changes
Milestone

Comments

@xuanyuan300
Copy link
Contributor

xuanyuan300 commented Jun 13, 2022

Read-write-splitting is an important part of pisa-proxy traffic management, which can be improve query performance and reduce server load in practical scenarios.

The following is internal design diagram:
image

RuleMatch is used to match SQL statements by rules. Currently, only support regex and in the future, rego will be supported.
TargetGroup is the backend target group after successful matching, and the target group corresponds to the role attribute, the role need to be defined in annotations field of DatabaseEndpoint crd.
LoadBalance is used to select an instance in the target group by the LoadBalance algorithm.
TargetInstace is executes the instance of the SQL statement.

An complete config of TrafficStrategy as follows:

apiVersion: core.database-mesh.io/v1alpha1
kind: TrafficStrategy
metadata:
  name: test 
  namespace: default 
spec:
  selector:
    matchLabels:
      source: test
  loadBalance:
    readWriteSplitting:
      static:  
        defaultTarget: read // or read_write
        rules:
          - name: read-rule
            type: regex
            regex: ".*"
            target: read // read_write
            algorithmName: random // lb algorithm
          - name: write-rule
            type: regex
            regex: ".*"
            target: read_write
            algorithmName: roundrobin

An complete config of DatabaseEndpoint as follows:

apiVersion: core.database-mesh.io/v1alpha1
kind: DatabaseEndpoint
metadata:
  annotations:
    database-mesh.io/role: read // or read_write
    database-mesh.io/weight: 1
  labels:
    source: test 
  name: mysql 
  namespace: default 
spec:
  database:
    MySQL:
      db: test 
      host: mysql.default 
      password: root 
      port: 3306
      user: root

Development Task

pisa-proxy

  • Add config for read_write_splitting.
  • Add RuleMatch engine.
  • Update build_loadbalance logic for RuleMatch engine.
  • Implement RuleMatch engine for mysql server runtime.
  • Implement new LoadBalancer to FSM.
  • Add unit test.

pisa-controller

  • Add config for read_write_splitting.
  • Update DatabaseEndpoint crd for role.

integration test

  • pisa-proxy and pisa-controller integration test.
@xuanyuan300 xuanyuan300 added the app:pisa-proxy Pisa-Proxy related changes label Jun 13, 2022
@xuanyuan300 xuanyuan300 self-assigned this Jun 13, 2022
@xuanyuan300 xuanyuan300 added the in:strategy Strategy related changes label Jun 13, 2022
@xuanyuan300 xuanyuan300 added this to the v0.1.1 milestone Jun 13, 2022
@mlycore mlycore changed the title Feature(strategy): WIP: support mysql read_write_splitting Feature(strategy): support mysql read_write_splitting Jun 23, 2022
@mlycore mlycore reopened this Jun 23, 2022
@mlycore
Copy link
Member

mlycore commented Jun 23, 2022

The TODOs need to be updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:pisa-proxy Pisa-Proxy related changes in:strategy Strategy related changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants