Design and Implementation of CFL: A MySQL Time‑Series Storage Engine
This article presents the design, architecture, and performance evaluation of CFL, a MySQL time‑series storage engine developed by Ctrip, detailing its functional and interface layers, storage strategy, and benchmark results compared with InnoDB, MyISAM, and other engines.
Author : Jiang Yuxiang, Senior Researcher at Ctrip Technology Assurance Center, with over ten years of experience in database development, including contributions to the domestic DM (DaMeng) database series and MySQL source code research.
MySQL offers flexible data management through multiple storage engines such as InnoDB (ACID‑compliant) and Blackhole (no‑op). However, native MySQL storage‑engine development remains a niche field in China, prompting the team to explore a new engine tailored for time‑series data.
The idea originated from a discussion about the most suitable time‑series database for Ctrip. The team proposed building a MySQL‑based time‑series engine to avoid the deployment complexity of solutions like OpenTSDB (which relies on HBase) and to retain familiar SQL access.
The envisioned architecture keeps the MySQL user experience unchanged: existing HA, replication, backup, and CRUD operations are preserved, while the underlying storage component is swapped out for a purpose‑built time‑series backend.
The resulting prototype, named CFL (Ctrip Fast Log), records data using a fast‑log approach, allowing parallel insertion from multiple sessions, buffering writes in memory, and flushing to disk via dedicated writer threads.
Technical Introduction
MySQL storage engines consist of two layers: the functional layer , which implements core data operations (insert, delete, update, query), and the interface layer , which maps MySQL handler calls (e.g., ha_open, ha_close) to the functional layer.
Functional Layer
The functional layer of CFL focuses on high‑throughput inserts. It adopts a strict sequential‑write policy to maximize write speed on both HDD and SSD, and stores index and data in separate files to simplify management. By controlling the write order (data → index → control information), rapid crash recovery is achieved.
Interface Layer
The interface layer implements a handler class derived from MySQL's base handler. The concrete class ha_cfl translates MySQL operations into calls to the functional layer. The following diagram illustrates the flow from SQL to the engine’s internal objects.
Performance Evaluation
The benchmark compares CFL with MyISAM, InnoDB, and the native MySQL engines under varying numbers of insert threads. Results (in inserts per second) show that CFL consistently outperforms the others, achieving up to 8,400 ips with six threads, versus 6,000 ips for InnoDB and 5,700 ips for MyISAM.
Engine\Insert Threads
1 Thread (ips)
3 Threads (ips)
6 Threads (ips)
CFL
3700
5700
8400
MyISAM
3300
4500
6000
InnoDB
1900
2100
3000
Conclusion
The project is exploratory; limited time and resources mean some features (e.g., multi‑column indexes, efficient delete/update) are incomplete. Nevertheless, the team delivered a functional prototype, deepened understanding of MySQL storage‑engine internals, and gathered valuable experience that can benefit the broader MySQL community in China.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ctrip Technology
Official Ctrip Technology account, sharing and discussing growth.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
