## Overview

<!-- markdownlint-disable MD032 -->
> [!NOTE]
> This lab only supports Chrome browser.

During the migration from MySQL to TiDB, it is often necessary to verify the compatibility and performance of applications' SQLs. The TiDB Real Traffic Replay Tool can be used to reapply traffic files obtained from MySQL slow queries or packet captures to the TiDB cluster. This tool can complete real traffic validation for compatibility or performance, enhancing the success rate of database migration.

  ![80%](https://lab-static.pingcap.com/quick-demo/demo-302-1-en.png)

### The core features of `sql-replay`

+ Log capture and parsing
  + `MySQL slow log` files or files generated by `parse-tshark captures` include SQL execution times and SQL text. The tool can parse these logs to extract relevant information such as SQL statements, execution times, and possibly other metadata like execution context or the user executing the query.

+ Query replay
  + Replay the extracted SQL queries to the TiDB cluster in a controlled environment.

+ Performance measurement and analysis
  + During replay, the execution times of SQL queries in the TiDB cluster are obtained.
  + These metrics are compared with benchmarks or previous runs to identify performance degradation or improvements, helping pinpoint specific queries or database settings that may cause issues.

+ Report generation
  + Finally, sql-replay generates reports providing insights into query compatibility and performance. These reports help database administrators and developers understand the impact of different queries on the system and make informed optimization decisions.

### Tasks

+ Setup upstream MySQL and downstream TiDB environment.
+ Capture and replay SQLs by `sql-replay` tool.
+ Capture SQLs by `parse-tshark` tool and replay them by `sql-replay` tool.

> [!TIP]
> Click **Start** to launch the lab environment.
> Once the environment is ready, the resources assigned to your hands-on session will be populated with the actual values, so you can follow the lab guide step-by-step to complete the practice.
