本文介紹 OceanBase 資料庫在開啟和未開啟 TDE 加密情境下的資料庫效能的影響,協助您評估是否選擇開啟 TDE 加密。
測試結論
開啟 TDE 功能後,使用 128/256 並發測試 OLTP 情境,其中 update 情境效能無影響,但其他情境效能略有損耗。
point select 情境效能損失 3%左右,read_only 情境效能損失 1% 左右。
read write 情境效能損失 2%左右,write only 情境效能損失 1% 左右,insert 情境效能損失 1% 左右。
整體來看,在單點查詢情境 point select、讀寫情境 read write 效能損失較為明顯,但均在 3% 以下。
測試環境
叢集配置
配置項
相關配置
叢集版本
OceanBase 4.2.1.8 版本
叢集規格
2F1A,primary zone=zone1,8C16G
叢集機器
CPU:8C
記憶體:61G
用戶端配置
配置項
相關配置
作業系統
Linux iZbp1eodxjpfw80wly2g4oZ 5.10.134-16.3.al8.x86_64 #1 SMP Tue Mar 26 18:54:05 CST 2024 x86_64 x86_64 x86_64 GNU/Linux
sysbench 版本
sysbench 1.0.20
cpu 規格
8C
記憶體
30G
測試載入器
sysbench 是一個跨平台且支援多線程的模組化基準開源測試載入器,用於評估系統在運行高負載資料庫時的效能。
測試單位
每秒執行事務數 TPS(Transactions Per Second):資料庫每秒執行的事務數,以 COMMIT 成功次數為準。
交易處理平均延遲(Average Latency):資料庫執行一條事務的平均耗時,單位為毫秒(ms)。
測試步驟
本次測試以 128 張表,每張表資料量為 100 萬條,執行時間為 60 秒為例。
安裝 sysbench 工具
sysbench 工具使用yum install一鍵安裝或者通過手動方式安裝。
使用
yum install一鍵安裝。在用戶端機器上,執行如下命令,安裝 sysbench 工具。
sudo yum install sysbench手動安裝
下載 sysbench。
sysbench 工具下載,請參考 sysbench 下載。
解壓 sysbench。
unzip ./1.0.20.zip編譯 sysbench。
進入 sysbench 解壓後的目錄,運行以下命令編譯 sysbench:
[w****@localhost ~]# cd sysbench-1.0.20 [w****@localhost sysbench-1.0.20]# ./autogen.sh [w****@localhost sysbench-1.0.20]# ./configure --prefix=/usr/sysbench/ --with-mysql-includes=/usr/include/mysql/ --with-mysql-libs=/usr/lib64/mysql/ --with-mysql [w****@localhost sysbench-1.0.20]# make [w****@localhost sysbench-1.0.20]# make install參數說明:
參數名
說明
--prefix
指定 sysbench 的安裝目錄。
--with-mysql-includes
指定 mysql 的 includes 目錄。
--with-mysql-libs
指定 mysql 的 lib 目錄。
--with-mysql
sysbench 預設支援 MySQL。
運行以下命令,驗證 sysbench 是否安裝成功:
[w****@localhost sysbench-1.0.20] $./src/sysbench --help如果返回以下資訊,則 sysbench 安裝成功。
Usage: sysbench [options]... [testname] [command] Commands implemented by most tests: prepare run cleanup help
執行測試
測試其他線程及指令碼的流程與下述測試流程一致。
下述測試流程以 MySQL 租戶,線程數為 128 ,建立表為 128 張,每張表資料為 100 萬,執行時間為 60 秒,測試指令碼為 read write 為例。
MySQL 模式的資料庫環境建立,詳細步驟可參見 購買執行個體 > 建立租戶 > 建立帳號 > 建立資料庫(僅 MySQL)。
登入測試租戶。登入資料庫的串連串資訊,請參見 擷取串連參數。
obclient -h$host -P$port -u$user_name -p******清除垃圾資料,空出部分資料盤空間。
obclient> PURGE RECYCLEBIN;設定逾時時間。
obclient > set global ob_query_timeout=36000000000;設定透明加密方式,關於設定透明加密方式詳細資料,可參考 開啟 TDE 透明加密。
退出資料庫,使用 sysbench 工具載入測試資料。
[w****@localhost src]# ./sysbench --db-driver=mysql --mysql-host=[database server host] --mysql-port=[database server port] --mysql-user=[database user name] --mysql-password=[database user password] --mysql-db=testdb --table_size=1000000 --tables=128 --threads=128 --time=60 oltp_read_write prepare執行自訂測試指令碼。
[w****@localhost src]# ./sysbench --db-driver=mysql --mysql-host=[database server host] --mysql-port=[database server port] --mysql-user=[database user name] --mysql-password=[database user password] --mysql-db=testdb --table_size=1000000 --tables=128 --threads=128 --time=60 oltp_read_write run清理資料。
[w****@localhost src]# ./sysbench --db-driver=mysql --mysql-host=[database server host] --mysql-port=[database server port] --mysql-user=[database user name] --mysql-password=[database user password] --mysql-db=testdb --table_size=1000000 --tables=128 --threads=128 --time=60 oltp_read_write cleanup
測試結果
測試指令碼/線程數 | 是否開啟 TDE | 128(tps/rt avg) | 256(tps/rt avg) | rate |
point select | TDE 關 | 161720.04/0.79 | 172429.16/1.48 | \ |
point select | TDE 開 | 161113.90/0.79 | 167284.47/1.53 | -2.98% |
read only | TDE 關 | 6571.77/19.47 | 6877.75/37.19 | \ |
read only | TDE 開 | 6558.48/15.51 | 6813.74/37.54 | -0.93% |
read write | TDE 關 | 3483.70/36.10 | 3575.20/71.50 | \ |
read write | TDE 開 | 3391.10/37.72 | 3572.78/71.55 | -2.61% |
insert | TDE 關 | 37806.09/3.38 | 54585.23/4.69 | \ |
insert | TDE 開 | 37121.78/3.45 | 54353.98/4.71 | -0.42% |
update | TDE 關 | 29743.67/4.30 | 38743.35/6.61 | \ |
update | TDE 開 | 29866.70/4.28 | 38905.09/6.58 | 無影響 |
update non index | TDE 關 | 38892.58/3.29 | 55662.11/4.60 | \ |
update non index | TDE 開 | 39250.25/3.26 | 56661.89/4.52 | 無影響 |
write_only | TDE 關 | 11583.12/11.05 | 12395.72/20.64 | \ |
write_only | TDE 開 | 11450.32/11.17 | 12259.25/20.87 | -1.10% |
上述表格中,rate 中的-表示效能下降。例如:point select 在 TDE 開啟後,效能會下降 2.98% 。