Performance Testing Service (PTS) connects to your database through Java Database Connectivity (JDBC), runs a SQL query, and maps the returned columns to named parameters. Virtual users consume these parameters during stress testing, so each request carries production-like data instead of static values.
PTS supports the following ApsaraDB RDS database types:
ApsaraDB RDS for MySQL
ApsaraDB RDS for PostgreSQL
ApsaraDB RDS for MariaDB
ApsaraDB RDS for SQL Server
JDBC URL format
The JDBC URL specifies the location of your database. The format varies by database type:
| Database type | JDBC URL format | Example |
|---|---|---|
| MySQL | jdbc:mysql://<host>:<port>/<database> | jdbc:mysql://rm-bp1xxxxx.mysql.rds.aliyuncs.com:3306/testdb |
| PostgreSQL | jdbc:postgresql://<host>:<port>/<database> | jdbc:postgresql://rm-bp1xxxxx.pg.rds.aliyuncs.com:5432/testdb |
| MariaDB | jdbc:mariadb://<host>:<port>/<database> | jdbc:mariadb://rm-bp1xxxxx.mariadb.rds.aliyuncs.com:3306/testdb |
| SQL Server | jdbc:sqlserver://<host>:<port>;databaseName=<database> | jdbc:sqlserver://rm-bp1xxxxx.sqlserver.rds.aliyuncs.com:1433;databaseName=testdb |
| Placeholder | Description | Example |
|---|---|---|
<host> | The endpoint of your ApsaraDB RDS instance | rm-bp1xxxxx.mysql.rds.aliyuncs.com |
<port> | The port number of your RDS instance | 3306 |
<database> | The name of the database to connect to | testdb |
Create a database data source parameter
Before you begin, make sure that:
Your ApsaraDB RDS instance is running
You have a database account with read permissions on the target tables
You have the JDBC URL, username, and password for your database
To create a database data source parameter, perform the following steps:
Log on to the PTS console. In the left-side navigation pane, choose Performance Test > Create Scenario, and then click PTS.
Click Data Sources. On the Databases tab, click + Add Data Source. Configure the database connection:
Setting Description Database type The type of your ApsaraDB RDS database. Select MySQL, PostgreSQL, MariaDB, or SQL Server. Database URL The JDBC URL of your database. See the JDBC URL format section for the correct syntax. Username The username of the database account. Password The password of the database account. Query statement A SQL statement that starts with Select. This query retrieves the test data that PTS injects into your scenario parameters. Example:Select user_id, email FROM users LIMIT 10000.Click Add Parameter. Configure the parameter mapping, and then click Save: To map multiple columns, repeat this step for each column you need.
Setting Description Parameter name A name for the parameter. Use this name to reference the parameter in your stress testing scenario. Column index The column position in the SQL result set to map to this parameter. Data source The database data source you configured in the previous step.
Write efficient queries
Select only the columns your test needs. Avoid Select * queries, which return unnecessary data and slow down the preparation phase.
Add a
LIMITclause to control the result set size. Example:Select user_id, email FROM users LIMIT 10000.Use
WHEREclauses to filter for relevant test data instead of returning the entire table.
The full result set loads during the preparation phase before stress testing starts. Large result sets slow down this phase and increase memory usage. Return only the columns and rows your test scenarios require.
Secure database access
Use a dedicated database account with read-only permissions. Do not use an admin or root account.
Restrict the account to only the tables required for testing.
Limits
SQL statements must start with
Select. PTS does not support INSERT, UPDATE, DELETE, or other write operations.The full result set loads into memory before the stress test starts. Larger result sets increase preparation time and memory usage.