A System Performance Estimation Model for Cassandra Database

Bo-Qian Wang, Qi Yu, Xin Liu, Shen Li, Zhiying WangInternational Journal of Database Theory and Application 2016

Abstract: Cassandra database system is one of the universal databases. To achieve high performance, we should allocate memory space rationally according to actual demands. Otherwise, it will influence reading and writing performance. Actually, we always allocate memory space according to experience and repeated attempts which usually won’t give us the best answer. To solve this problem, firstly we analyze the reading and writing processing of the Cassandra database and find out the corresponding memory space which will influence system performance. Secondly, we build up a relationship model between system performance and memory allocation and name it as The Memory Model of Reading and Writing Performance. We have already applied the relationship model to real database servers to guide memory allocation and performance evaluation. Simulation results show that this memory model could well describe the quantization relationship of memory space and system performance.

Introduction

Tuning Cassandra’s memory allocation is traditionally a process of trial and error. As a distributed NoSQL powerhouse, Cassandra's performance is highly sensitive to how RAM is partitioned. Administrators face a fundamental trade-off: every megabyte assigned to the JVM heap—primarily for Memtables to accelerate writes—is a megabyte subtracted from the operating system’s page cache, which is critical for accelerating disk reads. This paper proposes a mathematical framework to move from experience-based guessing to quantitative optimization.

Memory Architecture and Process Analysis

To build an accurate model, the researchers first mapped the data flow within Cassandra. Writes involve the CommitLog and Memtables, while reads navigate a hierarchy of Memtables, Row/Key Caches, Bloom Filters, and SStables on disk.

Central to this study is the division of system memory. As shown in the memory layout, the total RAM is split between the Java heap (containing Memtables and non-memtable objects), the OS cache (including Key/Row caches and general cached memory), and system overhead.

Cassandra Memory Layout

Methodology and Modeling

The researchers utilized the Yahoo Cloud Serving Benchmark (YCSB) on a controlled Ubuntu environment to observe performance breaking points. They focused on a Zipfian distribution for data access, mimicking real-world "hot" data patterns.

The resulting mathematical models are:

  • Read Model: A logarithmic formula, $time = a + b \cdot \ln(mem)$, describing how increased page cache memory reduces read latency.
  • Write Model: A function of Memtable size, balancing the benefits of fewer disk flushes against the risks of I/O queue congestion.
  • Performance Weighting: A composite formula ($Perf$) allowing users to weight read and write throughput ($rate_{read}$ and $rate_{write}$) based on specific application needs.

Experimental Results

The models demonstrated exceptional accuracy, with R-squared values of 0.998 for reads and 0.999 for writes. The core finding was the "zero-sum" relationship between read and write throughput as JVM heap size varies.

Throughput vs JVM Size

As illustrated in the graph, increasing the JVM size improves load (write) throughput by allowing larger Memtables, but it simultaneously degrades read throughput by starving the OS page cache. In an 8GB RAM environment, a 1GB JVM heap often provided the optimal balance.

Key Insights

  • Cache Redundancy: Internal key_cache and row_cache can sometimes hinder performance. Since the Linux kernel's page cache is highly optimized, internal caches can create data redundancy, wasting RAM that could be better utilized by the OS.
  • Memtable Limits: While larger Memtables reduce flush frequency, exceeding a certain threshold (e.g., 800MB in tests) causes massive I/O stalls during flushes, dropping throughput to zero for extended periods. A 400MB Memtable achieved 2911 ops/s, whereas an 800MB Memtable performed worse at 2847 ops/s due to these stalls.

Conclusion and Future Work

While the model provides a robust foundation for single-node optimization, it currently focuses on local memory dynamics. Future research will extend this to distributed cluster factors like gossip traffic. Additionally, while the model's structure is universal, the specific constants must be calibrated for different hardware environments to ensure peak accuracy.

Summary updated

BibTeX
@article{wang2016system,
  author = {Bo-Qian Wang and Qi Yu and Xin Liu and Shen Li and Zhiying Wang},
  title = {{A System Performance Estimation Model for Cassandra Database}},
  journal = {International Journal of Database Theory and Application},
  year = {2016},
  doi = {10.14257/ijdta.2016.9.3.14},
}
Figure