TRAFFIC REPLAY

TiDB v9.0.0 introduces the TRAFFIC REPLAY syntax, which is used to send requests to all TiProxy instances in the cluster, allowing TiProxy to replay traffic from the traffic file to TiDB.

To replay traffic, the current user must have the SUPER or TRAFFIC_REPLAY_ADMIN privilege.

TRAFFIC REPLAY supports the following options:

  • USER: (required) specifies the database username for replay.
  • PASSWORD: (optional) specifies the password for the username. The default value is an empty string "".
  • SPEED: (optional) specifies the replay speed multiplier. The range is [0.1, 10]. The default value is 1, indicating replay at the original speed.
  • READ_ONLY: (optional) specifies whether to replay only read-only SQL statements. true means to replay only read-only SQL statements, false means to replay all SQL statements. The default value is false.

Synopsis

TrafficStmt
TRAFFICREPLAYFROMstringLitTrafficReplayOptList
TrafficReplayOptList
TrafficReplayOptTrafficReplayOptListTrafficReplayOpt
TrafficReplayOpt
USEREqOptstringLitPASSWORDEqOptstringLitSPEEDEqOptNumLiteralREAD_ONLYEqOptBoolean

Examples

Replay traffic from the local /tmp/traffic directory of the TiProxy instance, using the TiDB user u1, whose password is "123456":

TRAFFIC REPLAY FROM "/tmp/traffic" USER="u1" PASSWORD="123456";

Replay traffic from the traffic files stored in the S3 storage:

TRAFFIC REPLAY FROM "s3://external/traffic?access-key=${access-key}&secret-access-key=${secret-access-key}" USER="u1" PASSWORD="123456";

Replay traffic at double speed:

TRAFFIC REPLAY FROM "/tmp/traffic" USER="u1" PASSWORD="123456" SPEED=2;

Replay only read-only statements, not write statements:

TRAFFIC REPLAY FROM "/tmp/traffic" USER="u1" PASSWORD="123456" READ_ONLY=true;

MySQL compatibility

This statement is a TiDB extension to MySQL syntax.

See also

Was this page helpful?