OceanBase Database is based on the LSM-Tree storage architecture and a native distributed design, delivering excellent throughput and low latency in high-concurrency transaction processing (OLTP) scenarios. This topic helps you directly experience the OLTP capabilities of OceanBase Database through data import and stress testing.
This topic covers the following experiences:
- Data import: Use direct load to experience OceanBase Database's high-throughput data loading capability.
- Sysbench stress testing: Use
obd test sysbenchto start an OLTP benchmark in one step and experience high-concurrency read/write performance. - TPC-C stress testing: Use
obd test tpccto start a TPC-C test in one step and experience high-concurrency transaction processing.
Note
This topic is written based on OceanBase Database V5.0.1 (Community Edition). The commands and feature descriptions in this topic apply to V5.0.1. This topic uses a single-node environment deployed with the All-in-One package in Deploy OceanBase as an example. If you deployed OceanBase Database with RPM packages (systemd), the obd test command is unavailable. In that case, see OceanBase Database Sysbench Test and OceanBase Database TPC-C Test to perform stress testing manually.
Prerequisites
Before you perform the operations in this topic, ensure that the following conditions are met:
Project |
Description |
|---|---|
| OceanBase Database | OceanBase Database has been deployed and started successfully. For more information, see Deploy OceanBase Database. |
| Deployment method | Deployed with the All-in-One package (obd demo), with the deployment name demo. |
| Hardware recommendations | For stress testing, we recommend at least 4 CPU cores and 16 GB of memory. The higher the specifications, the better the results reflect the performance of the database. |
| obclient | obclient is installed and can connect to OceanBase Database normally. It is installed automatically when you deploy with the All-in-One package. |
| Network | Make sure that the default port 2881 of OceanBase Database is not blocked by the firewall. |
In the command-line examples below, a leading $ indicates that the command is run as a regular user, and obclient [database name]> indicates that an SQL statement is run in a database session. Do not type the prompt itself.
Create a test tenant
The sys tenant is a built-in management tenant in OceanBase Database, used for cluster management and maintenance operations. It is not recommended to use the sys tenant directly for stress testing. Before performing data import and stress testing, you must first create an independent business tenant and allocate appropriate resource specifications to it.
Resource specification description
OceanBase Database allocates computing resources through the hierarchy "Unit Config → Resource Pool → Tenant". A unit config defines the CPU and memory specifications, representing the upper limit of resources available to a tenant.
Notice
Resource specifications directly affect the stress test results. Specifications that are too low may make memory or CPU a bottleneck, while specifications that are too high may exceed the resource limit of a single node. Set MAX_CPU and MEMORY_SIZE appropriately based on the actual configuration of your machine. For details, see Experience multi-tenancy and resource isolation.
Procedure
Log in to the sys tenant of the cluster as the root user (the password is randomly generated during deployment and can be found in the deployment output or in the output of the
obd cluster display democommand. For details, see Deploy OceanBase):$ obclient -h127.0.0.1 -uroot@sys -P2881 -p -A oceanbaseCreate a unit config. The following example creates a 2C4G unit config. You can adjust
MAX_CPUandMEMORY_SIZEbased on your machine configuration:obclient [oceanbase]> CREATE RESOURCE UNIT oltp_unit MAX_CPU=2, MIN_CPU=2, MEMORY_SIZE='4G';The return result is
Query OK, 0 rows affected.Create a resource pool and associate it with the unit config. For a single-node cluster, the
ZONE_LISTis('zone1'):obclient [oceanbase]> CREATE RESOURCE POOL oltp_pool UNIT='oltp_unit', UNIT_NUM=1, ZONE_LIST=('zone1');The return result is
Query OK, 0 rows affected.Create a MySQL-compatible tenant, associate it with the resource pool, and set the allowlist:
obclient [oceanbase]> CREATE TENANT IF NOT EXISTS oltp_tenant CHARSET='utf8mb4', PRIMARY_ZONE='zone1', RESOURCE_POOL_LIST=('oltp_pool') SET ob_tcp_invited_nodes='%';The return result is
Query OK, 0 rows affected. Resources are actually allocated when the tenant is created, which takes some time. Please be patient.Confirm that the tenant has been created successfully:
obclient [oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, STATUS FROM DBA_OB_TENANTS;When a record with
TENANT_NAMEasoltp_tenantandSTATUSasNORMALappears in the query result, the tenant has been created successfully (the query result also includes records for the sys tenant and its corresponding Meta tenant). For detailed column descriptions, see DBA_OB_TENANTS.Log in to the new
oltp_tenanttenant. The root user of a new tenant has an empty password by default, so press Enter when prompted.testis the default empty database that comes with the tenant and can be used for testing directly. All subsequent operations are performed in this tenant:$ obclient -h127.0.0.1 -uroot@oltp_tenant -P2881 -p -A test
Note
If you need to create a tenant in a three-node cluster, ZONE_LIST should include all zones, and PRIMARY_ZONE can be set to RANDOM to achieve random leader distribution. For more information, see Experience multi-tenancy and resource isolation.
Experience data import
OceanBase Database supports multiple data import methods. Among them, direct load bypasses the SQL layer and the memory table (MemTable), writing data directly to the underlying storage (SSTable), thereby significantly improving the throughput of large-scale data loading.
Direct load is suitable for the following scenarios:
- Full data loading during data migration and synchronization
- Large-scale data import in ETL processes
- Loading data from text files or other data sources into OceanBase
Note
Direct load is a import execution mode, not an independent syntax category. You can enable direct load by adding the DIRECT(...) hint to statements such as LOAD DATA and INSERT INTO SELECT. For more information, see Overview of direct load.
Procedure
The following example uses LOAD DATA INFILE combined with the direct load hint to import data from a CSV file into a test table.
Prepare the test data file on the machine where the OBServer node resides:
$ cat > /tmp/tbl1.csv << 'EOF' 1,11 2,22 3,33 EOFSet the
secure_file_privsystem variable to allow OceanBase to read files from the/tmpdirectory. For security reasons, this variable can only be modified over a local Unix Socket connection. The socket file path depends on the deployment method (it is usually~/oceanbase-ce/run/sql.sockforobd demo). Find the path with the following command, and then use it to connect to theoltp_tenanttenant (the root user password of the tenant is empty by default; press Enter when prompted):$ find / -name sql.sock 2>/dev/null $ obclient -S /path/to/sql.sock -uroot@oltp_tenant -pAfter a successful connection, execute the following statement:
obclient [(none)]> SET GLOBAL secure_file_priv = "/tmp";Note
secure_file_privrestricts the file access paths for statements likeLOAD DATA INFILE. Modifications take effect after reconnecting to the database. For more information, see secure_file_priv.Reconnect to the
oltp_tenanttenant and create a test table:$ obclient -h127.0.0.1 -uroot@oltp_tenant -P2881 -p -A testobclient [test]> CREATE TABLE tbl2 ( col1 INT PRIMARY KEY, col2 INT );The return result is
Query OK, 0 rows affected.Use direct load to import the data from the CSV file into the
tbl2table:obclient [test]> LOAD DATA /*+ direct(true,1024,'full') parallel(4) */ INFILE '/tmp/tbl1.csv' INTO TABLE tbl2 FIELDS TERMINATED BY ',';Note
In the hint,
direct(true,1024,'full')enables full direct load, andparallel(4)sets the degree of parallelism to 4. Full direct load is suitable for the initial loading of an empty table. If the target table already contains data, you can change the third parameter to'inc'(incremental direct load) or'inc_replace'(incremental replace). For more information, see Import data by using the LOAD DATA statement.After the command is successfully executed, obclient returns the import result, which includes the number of affected rows, skipped rows, and warnings:
Query OK, 3 rows affected Records: 3 Deleted: 0 Skipped: 0 Warnings: 0Note
To evaluate the performance advantages of direct load, you can use the
timecommand in the operating system together withobclient -eto execute theLOAD DATAstatement with and without theDIRECThint to import the same data and compare the execution times. For details, see Experience parallel import and high compression. Direct load skips the SQL layer and MemTable, so the import speed is usually significantly faster than regular import in scenarios with large data volumes.Verify whether the data was imported successfully:
obclient [test]> SELECT * FROM tbl2;The following return result indicates a successful import:
+------+------+ | col1 | col2 | +------+------+ | 1 | 11 | | 2 | 22 | | 3 | 33 | +------+------+
Experience Sysbench stress testing
Sysbench is a multi-threaded benchmarking tool based on LuaJIT that is commonly used to evaluate database performance under different workloads. OceanBase provides the obd test sysbench command, which can generate test data, tune parameters, load data, and run a stress test in one step.
About Sysbench
Sysbench primarily includes the following OLTP test scenarios:
oltp_read_only: read-only testoltp_write_only: write-only testoltp_read_write: read/write mixed testoltp_point_select: point query test
Procedure
Install ob-sysbench:
$ sudo yum install -y yum-utils $ sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo $ sudo yum install ob-sysbenchNote
If your machine cannot connect to the external network, we recommend using a machine that can access the internet to visit OceanBase Developer Tools Download. Download the corresponding installation package for your system version and upload it for installation.
If you receive the error
404 for .../repodata/repomd.xmlwhen executingyum install(for example, if the system version is not within the el7/8/9 range supported by the image, such as on Alibaba Cloud Linux 3), you can append--releasever=8to the installation command to use the el8 image source. For example:sudo yum install ob-sysbench --releasever=8.
Run the following command as the same user that deployed
obd demoto start a read/write mixed stress test in one step. OBD locates the deployment from the current user's cluster configuration, so run this command under the account used for the deployment:$ obd test sysbench demo --tenant=oltp_tenant --script-name=oltp_read_write.lua --table-size=1000000 --threads=32 --rand-type=uniformKey parameters in the command:
ParameterDescriptiondemoThe deployment name, fixed as demowhen usingobd demofor deployment.--tenantThe name of the test tenant, which must be created in advance. --script-nameThe name of the Sysbench test script. Multiple names are supported, separated by commas. --table-sizeThe number of data rows initialized for each table, default is 20,000. --threadsThe number of concurrent threads. Multiple values are supported, separated by commas. --rand-typeThe random data generation function. We recommend using uniform.Note
obd test sysbenchautomatically completes all operations, including generating test data, tuning OceanBase parameters, loading data, and executing stress testing, requiring no additional intervention. If an error occurs during any step, you can refer to the obd test sysbench command to retry.The command initializes 30 tables by default (adjustable via
--tables).--table-size=1000000indicates loading 1 million rows of data per table. Data preparation time depends on the machine specifications. The stress test phase runs for 60 seconds by default, adjustable via--time. Note that the default maximum data disk size for a deployment byobd demois 8 GB. With the default 30 tables, each preparing 1 million rows, the peak usage from data loading and compaction will fill the data disk, causing the subsequent Experience TPC-C Stress Testing data preparation stage to become unresponsive for a long time. For minimum-specification deployment, we recommend reducing--table-size(e.g., to100000) or decreasing the number of tables via--tables.
View the test results. After the command finishes executing, Sysbench outputs the following key metrics:
MetricDescriptionQPS (Queries Per Second) The number of queries processed per second, which measures the database's query throughput. A higher value indicates stronger throughput capability. TPS (Transactions Per Second) The number of transactions processed per second, which measures transaction throughput capability. A higher value is better. 95% Latency (ms) The 95th percentile response time, indicating how many milliseconds it takes to complete 95% of requests. A lower value indicates lower latency. The following example shows the test results (actual values depend on hardware configuration and tenant specifications):
SQL statistics: transactions: 120000 (2000.00 per sec.) queries: 340000 (5666.67 per sec.) ... Latency (ms): min: 1.23 avg: 12.34 max: 98.76 95th percentile: 23.45Note
This document uses a single-node minimum-specification deployment. The test results are primarily used to verify the feature process and do not represent the production-level performance of OceanBase Database. For the official performance test report, see OceanBase Sysbench Performance Test Report. This report presents the test results for OceanBase Database V4.2.1 in a 3-node, 32C, 128G cluster environment, achieving QPS of 138,000 with a 95% latency of only 0.26 ms under Point Select with 32 threads.
You can also run multiple rounds of comparative testing with different scripts and thread counts to observe the trend of QPS increasing with concurrency and the growth of latency:
$ obd test sysbench demo --tenant=oltp_tenant --script-name=oltp_point_select.lua --table-size=1000000 --threads=64 --rand-type=uniform
Note
For Sysbench test results, refer to OceanBase Sysbench Performance Test Report. To manually install and run Sysbench, see the "Manually perform Sysbench testing" section in OceanBase Database Sysbench Testing.
Experience TPC-C stress testing
TPC-C is an OLTP performance benchmark developed by the TPC organization. It uses a merchandise sales model to test database systems and serves as an important reference for performance testing in the database industry. OceanBase Database broke the TPC-C world record twice, in 2019 and 2020.
OceanBase provides the obd test tpcc command, which can perform one-click generation of TPC-C test data, parameter tuning, data loading, and stress testing execution.
Procedure
Install obtpcc (TPC-C testing is based on BenchmarkSQL; you must also install the Java runtime environment. This step can be skipped if Java is already installed on your machine):
$ sudo yum install -y yum-utils $ sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo $ sudo yum install obtpcc javaIf you encounter issues such as a 404 error for the repository or no access to the external network during installation, see the instructions in Step 1 of "Experience Sysbench stress testing".
(Optional) If you have previously completed a Sysbench test using
--table-size=1000000, the test data will fill up the data disk of the minimum-specification deployment. You need to recreate thetestdatabase first to free up space (this operation will delete all data tables in the database, including the Sysbench test tables and thetbl2table created during data import).$ obclient -h127.0.0.1 -uroot@oltp_tenant -P2881 -p -A -e "DROP DATABASE IF EXISTS test; CREATE DATABASE test;"As the same user that deployed
obd demo, run the following command to start the TPC-C test in one step:$ obd test tpcc demo --tenant=oltp_tenant --warehouses=10 --run-mins=5Key parameters in the command:
ParameterDescriptiondemoThe deployment name, fixed as demowhen usingobd demo.--tenantThe test tenant name, which must be created in advance. --warehousesThe number of warehouses for the TPC-C test. The number of warehouses determines the test data scale, defaulting to 10. If not specified, it defaults to the cluster's CPU count × 20. --run-minsThe test execution time, in minutes. Default is 10 minutes. --load-workersThe concurrency level during data loading. If not specified, it defaults to the smaller value between the single-machine CPU count and the tenant's available memory (GB) / 2. --terminalsThe number of virtual terminals during testing. If not specified, it defaults to the smaller value between the cluster's CPU count × 15 and the number of warehouses × 10. Note
obd test tpccautomatically completes all operations, including test data generation, parameter tuning, data loading, and stress testing execution. The process lists detailed steps and outputs. A larger data volume takes longer.View the test results. After the command finishes executing, it outputs key TPC-C test metrics:
MetricDescriptionMeasured tpmC (NewOrders) New orders processed per minute. This is the core metric of the TPC-C test. A higher value indicates stronger transaction processing capability. Measured tpmTOTAL Total transactions processed per minute (including five types: new orders, payments, order status, delivery, and inventory queries). Transaction Count Total number of transactions completed during the test. A sample test result is shown below (actual values depend on hardware configuration and tenant specifications):
Measured tpmC (NewOrders) : 9968.91 Measured tpmTOTAL : 22048.03 Session Start = 2026-10-10 12:26:45 Session End = 2026-10-10 12:31:46 Transaction Count = 110406Note
tpmC (Transactions per Minute) is the core metric of the TPC-C benchmark, based on NewOrder transactions. This document uses a single-node minimum specification deployment, so the test results are primarily for verifying functional processes. For the official performance test report, see OceanBase TPC-C Performance Test Report. This report presents the test results for OceanBase Database V4.2.3 in a 3-node, 32C, 128G cluster with 1000 warehouses, achieving over 300,000 tpmC.
Note
To manually perform the TPC-C benchmark using BenchmarkSQL (including complete steps such as source code adaptation, table creation, and data loading), see OceanBase Database TPC-C Testing.
Next steps
After you complete the OLTP stress testing in this topic, you can explore the following:
- Experience HTAP mixed workload: Experience OceanBase Database's HTAP capability through row-store + column-store tables, running both transactional and analytical queries on the same table. For details, see Experience HTAP mixed workload scenarios.
- Experience multi-tenancy features: Create multiple business tenants to experience resource isolation and elastic scaling. For details, see Experience multi-tenancy and resource isolation.
- Distributed cluster stress testing: To experience OceanBase Database's scalable OLTP capability (linear expansion across multiple nodes), it is recommended to use a cluster of at least three nodes for testing, and set the tenant's
PRIMARY_ZONEtoRANDOM. For details, see OceanBase Database TPC-C testing.
References
- For detailed instructions on direct load, see Overview of direct load.
- For the complete syntax and more examples of the LOAD DATA statement, see Import data by using the LOAD DATA statement.
- For the complete steps of manual Sysbench testing, see Sysbench testing for OceanBase Database.
- For the complete steps of manual TPC-C testing, see TPC-C testing for OceanBase Database.
- For detailed parameters of OBD test commands, see Test command group.
- For creating and managing multi-tenancy, see Experience multi-tenancy and resource isolation.