Benchmarking Specialized Databases for High-frequency Data

Fazl Barez, Paul Bilokon, Ruijie XiongarXiv 2023

Abstract: This paper presents a benchmarking suite designed for the evaluation and comparison of time series databases for high-frequency data, with a focus on financial applications. The proposed suite comprises of four specialized databases: ClickHouse, InfluxDB, kdb+ and TimescaleDB. The results from the suite demonstrate that kdb+ has the highest performance amongst the tested databases, while also highlighting the strengths and weaknesses of each of the databases. The benchmarking suite was designed to provide an objective measure of the performance of these databases as well as to compare their capabilities for different types of data. This provides valuable insights into the suitability of different time series databases for different use cases and provides benchmarks that can be used to inform system design decisions.

Introduction

In the high-stakes world of quantitative finance, data is characterized by extreme velocity and volume. High-frequency trading (HFT) and real-time risk management systems generate millions of data points per second, often referred to as "tick" data. Traditional relational databases, such as standard PostgreSQL or MySQL, frequently struggle with these workloads because they are not optimized for the append-only nature of time-series data or the specific columnar access patterns required for financial mathematics.

While general benchmarks like TPC and YCSB exist, they fail to capture the nuances of financial order books and trade data. Furthermore, the industry-standard STAC-M3 benchmark is proprietary and often inaccessible to the broader research community. This paper addresses this gap by introducing a specialized, open-source benchmarking framework designed to evaluate modern time-series databases (TSDBs) against common financial calculations like Volume Weighted Average Price (VWAP) and Market Depth.

Methodology

The researchers evaluated four prominent databases: kdb+, InfluxDB, TimescaleDB, and ClickHouse. The benchmarking suite consists of 15 distinct tests categorized into five functional areas:

  1. Trades: Simple aggregations, such as calculating daily trading volume.
  2. Order Book: Calculations involving bid/ask spreads and market depth analysis.
  3. Complex Queries: Computationally intensive tasks, such as deriving hourly volatility from mid-quote returns.
  4. Writing: Bulk ingestion performance measurements.
  5. Storage Efficiency: Analysis of compression ratios and disk footprint.

To ensure a realistic evaluation, the study utilized 25.14 GB of real-world cryptocurrency exchange data (BTC-USD, ETH-USD, and USDT-USD) collected via the Cryptofeed library. This dataset included approximately 20 million trade records and 33 million order book updates. Tests were conducted using native query languages (q for kdb+, Flux for InfluxDB, and SQL for TimescaleDB and ClickHouse) and accounted for system caching effects to distinguish between raw disk I/O and in-memory performance.

Architectural Insights

The Columnar Advantage

A primary finding of the study is the significant performance advantage offered by columnar storage for financial analytics. Databases like kdb+ and ClickHouse store data by column rather than by row. This allows the system to read only the necessary data (e.g., just the "Price" or "Volume" columns) across millions of records, avoiding the overhead of reading entire rows.

Comparison of Row-Oriented vs. Column-Oriented Data Layouts and Access Patterns.

As illustrated in the figure above, row-oriented layouts require "jumping" across memory addresses to access specific columns, whereas column-oriented layouts allow for sequential, high-speed access to the same data type. This architectural choice is a major factor in the low query latencies observed in kdb+.

Memory vs. Disk and Storage Trade-offs

The benchmarks highlighted a clear trade-off between storage efficiency and query speed. InfluxDB achieved the highest compression ratio (83.73%), but its data model—which separates metrics into different series—requires expensive "pivoting" operations for complex math involving multiple columns. Conversely, kdb+ demonstrated that its in-memory mode is roughly 7x faster than its on-disk mode, justifying the heavy investment in RAM typical of high-frequency trading firms.

Key Performance Results

  • Ingestion Throughput: kdb+ led with 47.35 MB/s, followed by TimescaleDB at 30.19 MB/s. ClickHouse was significantly slower in this specific financial schema at 2.10 MB/s.
  • Query Latency: kdb+ (in-memory) was the fastest in nearly every category. For "Top of the Book" queries, kdb+ responded in 5ms, compared to 124ms for InfluxDB and 706ms for ClickHouse.
  • Storage Efficiency: InfluxDB outperformed the field with a compression ratio of 83.73%, compared to kdb+ (90.20%) and TimescaleDB (94.68%).
  • Resource Management: InfluxDB was notably efficient during execution, often using 1000x less memory than kdb+ to return results, making it a strong candidate for resource-constrained environments.

Conclusion

While kdb+ remains the performance leader for raw speed and ingestion, the study reveals that no single database is optimal for every scenario. InfluxDB provides superior storage efficiency and memory management, while TimescaleDB and ClickHouse offer the familiarity of SQL with varying performance profiles. Future work will expand this suite to include multi-threaded performance, concurrent user testing, and more complex machine learning-based analytics to further refine these benchmarks for enterprise-scale environments.

Summary updated

BibTeX
@misc{barez2023benchmarking,
  author = {Fazl Barez and Paul Bilokon and Ruijie Xiong},
  title = {{Benchmarking Specialized Databases for High-frequency Data}},
  year = {2023},
  eprint = {2301.12561},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.12561},
}
Figure