✏️ 작성자가 YCSB 실험을 위한 환경 세팅부터 빌드, benchmark 실행까지의 과정을 진행하며 기록한 문서입니다.
📌 Arm architecture (aarch64) 환경에서는 진행이 어려웠기에, amd64 환경에서 진행하시는 것을 권장드립니다.
🏗️ About YCSB
Yahoo! Cloud Serving Benchmark는 NoSQL과 KV database의 성능평가를 위해 디자인된 benchmarking framework이다.
GitHub - brianfrankcooper/YCSB: Yahoo! Cloud Serving Benchmark
Yahoo! Cloud Serving Benchmark. Contribute to brianfrankcooper/YCSB development by creating an account on GitHub.
github.com
다양한 workload를 테스트할 수 있고, throughput의 측정과 read, write, update 등의 operation에 대한 latency의 분석이 가능하다.
⚙️ Key Features of YCSB
- RocksDB, Cassandra, Redis, MongoDB, HBase 등 여러가지 database 지원
- Real-world database 시뮬레이션을 위한 Predefined workloads 제공
- Throughput (ops/sec), latency (ms/op) 측정
- 특정 use case를 위한 custom workload definition 가능
💻 Setting Experimental Environment
작성자의 환경Ubuntu 64-bit Arm Server 22.04.05 on Macbook Air M1 (VMWare Fusion)
Ubuntu 64-bit Arm Server 22.04.05 on LG Gram Pro (VirtualBox)
Disk : NVMe SSD
💽 Disk Partitioning
Partitioning이 뭔가?
- Storage에 “partition”이라고 불리는 새로운 영역을 생성하는 것.
- Disk slicing이라고도 불린다.
Partitioning이 왜 필요한가?
- 각각의 partition은 다른 file system으로 format이 가능하다.
- 분리된 영역으로 관리되기 때문에 실험 data가 기존의 파일들을 덮어쓰거나 삭제하는 사고를 방지할 수 있다.
- Fragmentation을 줄여 read/write consistency가 개선된다.
- Partition을 format하면 file의 생성과 삭제가 수차례 반복되는 long-running & heavy한 workload 수행으로 인해 fragmenation이 발생한 file system이 defragment 된다.
- 따라서 새로운 실험 진행시 data가 large, contiguous block들에 저장된다. 따라서 disk seek time이 줄어들고 benchmark가 더 stable한 환경에서 진행될 수 있도록 해준다.
- 실험을 반복하여 진행할 때 partition을 format하면 되므로 cleanup 및 reset이 편리해진다.
- 생성된 수많은 파일들을 모두 삭제하지 않아도 format만으로 reset이 가능하다.
- Orphaned file, 삭제된 inode, journal entry 등의 file system 잔여물들까지 완전히 제거가 가능하여 다음 실험이 확실한 clean state에서 시작됨을 보장한다.
어떻게 하는가?
1️⃣ 현재 disk 상태 파악
lsblk → System의 disk, partition structure를 보여준다
- nvme0n1p1 (partition 1) → EFI partition, 1GB
- Booting에 사용된다 (EFI firmware file 존재)
- /boot/efi에 mount 되어있다
- nvme0n1p2 (partition 2) → Boot partition, 2GB
- Kernel, bootloader file 존재
- /boot에 mount 되어있다
- nvme0n1p3 (partition 3) → Main partition, 346.9GB
- 가장 큰 partition
- 직접 사용되지 않고, LVM(Logical Volume Manager) setup의 일부
- ubuntu--vg-ubuntu--lv → LVM, 100GB
- Disk가 LVM을 사용하는 것임
- LVM이란?
- Storage의 Flexible resizing & management를 위한 framework
- About Logical Volume Management (LVM) | Ubuntu
- /에 mount 되어있다
2️⃣ 할당할 size 결정, 할당
50GB를 할당해보자
1. GParted 설치
sudo apt-get install gparted
2. GParted 실행 및 Partition Resize
sudo gparted
GParted를 종료한다.
3️⃣ Partition Mount
생성한 partition을 mount해준다.
Mount point 생성
sudo mkdir /mnt/ycsb_data
Partition mount
sudo mount /dev/nvme0n1p4 /mnt/ycsb_data
Reboot시에도 유지되도록 설정
1. Partition UUID 찾기
blkid | grep nvme0n1p4
/dev/nvme0n1p4: UUID="9d2f81a8-9d96-4cb3-94d6-7fa99f40d68a" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="02070e69-0edS7-4ddb-b866-20816647835d” 와 같은 정보가 출력된다
2. /etc/fstab를 수정
sudo vi /etc/fstab
가장 아래줄에 다음과 같이 작성해준 후 저장한다.
UUID=9d2f81a8-9d96-4cb3-94d6-7fa99f40d68a /mnt/ycsb_data ext4 defaults 0 2
🧱 Install and Build RocksDB
YCSB는 여러가지 database에 대한 binding을 제공하는데, 그 중 RocksDB를 사용하기 위해 우선 RocksDB를 준비해야 한다.
Download RocksDB
RocksDB v9.7.4 다운로드
Release RocksDB 9.7.4 · facebook/rocksdb
9.7.4 (2024-10-31) Bug Fixes Fix a leak of obsolete blob files left open until DB::Close(). This bug was introduced in version 9.4.0. 9.7.3 (2024-10-16) Behavior Changes OPTIONS file to be loade...
github.com
Dependencies 설치 (Ubuntu)
sudo apt update
sudo apt-get install libgflags-dev
sudo apt-get install libsnappy-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libbz2-dev
sudo apt-get install liblz4-dev
sudo apt-get install libzstd-dev
Compile RocksDB
cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8
[참고] There are few options when compiling RocksDB:
- [recommended] make static_lib will compile librocksdb.a, RocksDB static library. Compiles static library in release mode.
- make shared_lib will compile librocksdb.so, RocksDB shared library. Compiles shared library in release mode.
- make check will compile and run all the unit tests. make check will compile RocksDB in debug mode.
- make all will compile our static library, and all our tools and unit tests. Our tools depend on gflags 2.2.0 or newer. You will need to have gflags installed to run make all. This will compile RocksDB in debug mode. Don't use binaries compiled by make all in production.
각 Option에 따른 output file의 차이
Compile된 결과물은 RocksDB 사용목적에 따라 아래와 같이 활용된다.
make Target | Output | Mode | Use Case |
static_lib | librocksdb.a | Release | Production, static linking |
shared_lib | librocksdb.so | Release | Production, dynamic linking |
check | Tests & Debug build | Debug | Testing/debugging |
all | Static lib, tools, tests | Debug | Development & testing only |
🏭 Install YCSB
☝️ 방법 1: GitHub Releases에서 Prebuilt binary 다운로드
GitHub Releases에서 Prebuilt binary 다운로드
Getting Started
Yahoo! Cloud Serving Benchmark. Contribute to brianfrankcooper/YCSB development by creating an account on GitHub.
github.com
Download the Latest Version and Extract the file
curl -O --location <https://github.com/brianfrankcooper/YCSB/releases/download/0.17.0/ycsb-0.17.0.tar.gz>
tar xfvz ycsb-0.17.0.tar.gz
cd ycsb-0.17.0
☝️ 방법 2: Build from Source
⚠️ Java 8+와 Maven이 요구된다.
1️⃣ Install Java
sudo apt install openjdk-11-jdk
- Set JAVA_HOME and update PATH
- update-java-alternatives --list로 Java가 설치된 경로 확인
- 확인된 경로로 아래와 같이 export
echo 'export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-arm64' >> ~/.bashrc
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
- 확인: echo $JAVA_HOME
2️⃣ Install maven
sudo apt install maven
3️⃣ Clone the YCSB git repository and build
git clone git://github.com/brianfrankcooper/YCSB.git
cd YCSB
mvn clean package
🚚 Configure and Run YCSB
Database 경로 지정하여 YCSB Workload를 Load
Load Initial Data into RocksDB
sudo ./bin/ycsb load rocksdb -P workloads/workloada -p rocksdb.dir=/mnt/ycsb_data/rocksdb
- Workload를 workloada(A)로 지정해준다.
- YCSB가 RocksDB data를 /mnt/ycsb_data/rocksdb에 저장하도록 만들어준다.
⚠️ Python 관련 에러 발생시
YCSB는 Python3가 아닌 Python2를 사용한다.
따라서 아래와 같이 Python2를 설치해준다.
sudo apt update
sudo apt install python2
python2 --version
sudo ln -sf /usr/bin/python2 /usr/bin/python
⛔ AARCH 64-bit platform 관련 에러 발생시 → 해결 불가
추측: 위에서 RocksDB를 빌드할 때 make static_lib가 아닌 make shared_lib으로 빌드해야 한다
- 이유: 에러 메세지를 보면, “cannot open shared object file: No such file or directory (Possible cause: can’t load AMD 64-bit .so on a AARCH 64-bit platform” 이라고 말하고 있다. 따라서 현재 환경에 맞는 shared library 파일을 빌드하는 명령을 사용하여 .so 파일을 찾을 수 있도록 해줘야 하는 것으로 보였다. 그러나 바로 아래에서 시도했으나 빌드가 되지 않았다.
- 또는 그냥 make -j(nproc)
make clean 이후 다시 빌드 진행 (RocksDB)
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8
- Error 없이 빌드 완료
sudo rm -rf /database/* sudo ./db_bench --db=/database --num=50000000 --value_size=1024 --compression_type=none --benchmarks='fillrandom,stats' cp /database/LOG /log/rocksdb_$(date '+%Y-%m-%d').log
그러나 위의 YCSB 에러가 해결되지 않아, 직접 YCSB 소스에서 빌드하는 방법으로 변경해서 ✌️방법 2: Build from Source부터 다시 시도
- RocksDB Java Binding에서 또 같은 에러가 발생함
아래 방법으로 시도
No arm64/aarch64 support for rocksdbjni-xxx.jar · Issue #5559 · facebook/rocksdb
We are working on the ARM64 support for Storm project, and the Storm project is using rocksdbjni to play rocksdb. Unfortunately, there is no aarch64 support in rocksdbjni-xxx.jar, so we will get ba...
github.com
serin@serin-ubuntu:~/rocksdb-9.7.4$ export DEBUG_LEVEL=0
# build the aarch64 rocksdb jni jar
serin@serin-ubuntu:~/rocksdb-9.7.4$ make -j8 rocksdbjava
해결이 되지 않아, amd64 architecture 컴퓨터로 진행하는 것으로 결정
[작성자는 여기서부터 Windows (amd64)에 VirtualBox 설치하여 새로운 환경에서 처음부터 시도]
- 처음 환경세팅 등은 모두 동일하게 진행함
RocksDB 빌드 단계에서 에러 발생 케이스
cmake 에러 발생시
sudo apt-get install build-essential
‘dynamic_cast’ not permitted with ‘-fno-rtti’ 에러 발생시
CMakeLists.txt 아래와 같이 수정
set(USE_RTTI 1)
이후 아래와 같이 /mnt/ycsb_data/rocksdb에 data load가 완료되어 파일들이 생성된 것을 확인
YCSB Benchmark 실행
./bin/ycsb run rocksdb -P workloads/workloada -p rocksdb.dir=/mnt/ycsb_data/rocksdb
- workloada info → YCSB/workloads/workloada
# Yahoo! Cloud System Benchmark
# Workload A: Update heavy workload
# Application example: Session store recording recent actions
#
# Read/update ratio: 50/50
# Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
# Request distribution: zipfian
recordcount=1000
operationcount=1000
workload=site.ycsb.workloads.CoreWorkload
readallfields=true
readproportion=0.5
updateproportion=0.5
scanproportion=0
insertproportion=0
requestdistribution=zipfian
여기서, operationcount만 5,000,000으로 늘려서 실험을 하려면 아래와 같이 명령에 명시해주면 된다.
./bin/ycsb run rocksdb -P workloads/workloada -p operationcount=5000000 -p rocksdb.dir=/mnt/ycsb_data/rocksdb
다음 실험을 위해 Partition을 Format하려면
1. Unmount
lsblk로 format하고자 하는 partition 이름을 확인한 후, unmount 명령 실행
sudo umount /dev/sda4
2. Format
Ext4로 format하려면 아래와 같이 명령 실행
sudo mkfs.ext4 /dev/sda4
3. Mount
sudo mkdir -p /mnt/ycsb_data
sudo mount /dev/sda4 /mnt/ycsb_data
이러한 작업들은 script로 만들면 필요할 때마다 편리하게 사용할 수 있을 것이다.
Appendix
About Zipfian Distribution
YCSB’s Zipfian distribution은 소수의 item(key)들이 다른 item들보다 훨씬 자주 접근되는 real-world workload를 모방하기 위해 만들어졌다.
Zipf’s Law
즉, 𝜃가 0이면 모든 key들이 동일한 빈도로 접근되고, 𝜃가 1에 가까워질수록 몇몇 key들의 접근 빈도가 월등히 커지는 것이다.
YCSB의 구현
YCSB는 Zipfian generator를 Class로서 구현하였다.
YCSB/core/src/main/java/site/ycsb/generator/ZipfianGenerator.java at master · brianfrankcooper/YCSB
Yahoo! Cloud Serving Benchmark. Contribute to brianfrankcooper/YCSB development by creating an account on GitHub.
github.com
YCSB Benchmark 실행시 설정하는 방법
zipfian.constant 값을 명시해주면 된다.
./bin/ycsb run rocksdb -P workloads/workloada -p zipfian.constant=0.99
'Middleware System Softwares' 카테고리의 다른 글
[IEEE ICDE' 21] WipDB: A Write-in-place Key-value Store that Mimics Bucket Sort 논문 리뷰 (1) | 2025.04.13 |
---|