{"id":5691,"date":"2022-05-02T15:25:17","date_gmt":"2022-05-02T22:25:17","guid":{"rendered":"https:\/\/tdengine.com\/?p=5691"},"modified":"2025-11-03T08:04:54","modified_gmt":"2025-11-03T16:04:54","slug":"li-auto-migrates-iot-platform-from-mongodb-and-tidb","status":"publish","type":"post","link":"https:\/\/tdengine.com\/li-auto-migrates-iot-platform-from-mongodb-and-tidb\/","title":{"rendered":"Li Auto Migrates IoT Platform from MongoDB and TiDB"},"content":{"rendered":"\n<p>With the growth of business, the requirements for data storage performance in the IoT applications of Li Auto are constantly increasing. Our internal teams actively try to maintain industry best practices to match and optimize products and requirements. This article will explore why we chose and&nbsp;implemented&nbsp;TDengine for our IoT use cases.<\/p>\n\n\n\n<h2 class=\"gb-headline gb-headline-11fa6cd7 gb-headline-text\">Introduction to Business Requirements<\/h2>\n\n\n\n<p>Essentially, our application scenario involves signal writing and querying. We need to write time stamped data from collection points into the back-end database through the cloud, and then perform aggregation queries on this data. This is a typical high-concurrency insert scenario, with more writes and fewer reads. Currently there are 70,000 writes per second, and we expect to reach more than 200,000 writes per second in the next 3 years. <\/p>\n\n\n\n<p>Our previous system used MongoDB but due to the limitations of MongoDB, we migrated the business to TiDB to facilitate expansion. After migrating to TiDB on Baidu Cloud SSD virtual machines, the pure write performance of the TiDB cluster still could not meet our high performance business requirements. TiDB is a HTAP (Hybrid Transactional and Analytical Processing) database and does not perform well with high concurrency writes and could not scale without resource expansion.<\/p>\n\n\n\n<p>Overall, TiDB is suitable for TP or light AP scenarios, but it has high resource requirements for hardware. For time series data, the cost-effectiveness of writing to TiDB is very low. In addition, it imposes unnecessary complexity. The underlying database table must be built for each month, and each collection point must be labeled. It is also not optimal or even suitable to perform large batch writes. In general, the current architecture is unable to meet our requirements that are summarized below.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The system must support continuous high concurrency writes, with tags, and out of order timestamps.<\/li>\n\n\n\n<li>The business is expected to grow by orders of magnitude and the system should be able to scale automatically.<\/li>\n\n\n\n<li>The system must support aggregated queries over large time-spans.<\/li>\n\n\n\n<li>Because the amount of data is very large, it is necessary to support data compression to reduce costs and increase efficiency.<\/li>\n\n\n\n<li>There should be no need to separate data based on month and the system should support configurable, automatic time-based data expiration.<\/li>\n\n\n\n<li>Collection points should have separate tables.<\/li>\n\n\n\n<li>The system should support batch data writing with low latency.<\/li>\n<\/ul>\n\n\n\n<p>Based on these requirements, we decided to try the&nbsp;<a href=\"https:\/\/tdengine.com\/what-is-a-time-series-database\/\">time series database<\/a>&nbsp;(TSDB) TDengine. The performance and functionality of TDengine exceeded our expectations when we performed in-depth technical and business tests. Special thanks to Xiao Bo, Chen Weican and Yang Lina for their strong support. The following features of TDengine are well suited for our requirements.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Two-level storage structure, row-based in RAM and column-based on disk, with very high data ingestion performance and efficient resource utilization.<\/li>\n\n\n\n<li>Very high compression ratio for time series data.<\/li>\n\n\n\n<li>Create separate tables for collection points which matches our business requirements.<\/li>\n\n\n\n<li>Supports large multi-thread batch data writing.<\/li>\n\n\n\n<li>Transparent scale-out and scale-in.<\/li>\n\n\n\n<li>Automatic data expiration aka TTL is supported.<\/li>\n<\/ul>\n\n\n\n<p>TDengine&#8217;s excellent&nbsp;high concurrency&nbsp;writing and data compression capabilities greatly reduce business costs and it&#8217;s native clustering features ensure scalability. With all of this in mind, we decided to migrate from TiDB to TDengine.<\/p>\n\n\n\n<h2 class=\"gb-headline gb-headline-12f4ebc2 gb-headline-text\">Migration Process and Usage Costs<\/h2>\n\n\n\n<h3 class=\"gb-headline gb-headline-c3b02e25 gb-headline-text\">Migration Process<\/h3>\n\n\n\n<p>Migration plan:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Start writing new data to TDengine and keep historical read traffic in TiDB solution<\/li>\n\n\n\n<li>Historical data is gradually imported into TDengine<\/li>\n\n\n\n<li>Deployment scheme: The method of domain name\u2014&gt;LB\u2014&gt;firstEP+SecondEP is adopted. For details, please refer to the blog&nbsp;&#8220;Best Practices of TDengine Containerized Deployment&#8221; .<\/li>\n<\/ol>\n\n\n\n<figure class=\"gb-block-image gb-block-image-6d7a3bc0\"><img decoding=\"async\" width=\"1118\" height=\"897\" class=\"gb-image gb-image-6d7a3bc0\" src=\"https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration.jpg?strip=all&sharp=1\" alt=\"\" srcset=\"https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration.jpg?strip=all&amp;sharp=1 1118w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration-300x241.jpg?strip=all&amp;sharp=1 300w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration-1024x822.jpg?strip=all&amp;sharp=1 1024w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration-768x616.jpg?strip=all&amp;sharp=1 768w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration.jpg?strip=all&amp;sharp=1&amp;w=223 223w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration.jpg?strip=all&amp;sharp=1&amp;w=447 447w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration.jpg?strip=all&amp;sharp=1&amp;w=670 670w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/22.029-01-migration.jpg?strip=all&amp;sharp=1&amp;w=894 894w\" sizes=\"(max-width: 1118px) 100vw, 1118px\" \/><\/figure>\n\n\n\n<h2 class=\"gb-headline gb-headline-8371ad7c gb-headline-text\">Cost of Use<\/h2>\n\n\n\n<table id=\"tablepress-33\" class=\"tablepress tablepress-id-33\">\n<thead>\n<tr class=\"row-1\">\n\t<td class=\"column-1\"><\/td><th class=\"column-2\">TiDB<\/th><th class=\"column-3\">TDengine<\/th><th class=\"column-4\">Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n\t<td class=\"column-1\">Resource configurations<\/td><td class=\"column-2\">Total 17 nodes<br \/>\n5 TiDB servers<br \/>\n3 PD servers<br \/>\n12 TiKV servers (deployed on 12 nodes)<br \/>\n32-core\/64 GB SSD<\/td><td class=\"column-3\">32-core, 128 GB SSD<\/td><td class=\"column-4\">Except for a larger SSD, other configurations are the same as TiKV<\/td>\n<\/tr>\n<tr class=\"row-3\">\n\t<td class=\"column-1\">Resource consumption<\/td><td class=\"column-2\">IO: 70%<br \/>\nCPU: 40%<br \/>\nMemory: 20%<\/td><td class=\"column-3\">IO: 40%<br \/>\nCPU: 10%<br \/>\nMemory: 70%<\/td><td class=\"column-4\">TDengine is row-based storage in RAM and column-based storage on disk.<\/td>\n<\/tr>\n<tr class=\"row-4\">\n\t<td class=\"column-1\">Write latency<\/td><td class=\"column-2\">400 ms<\/td><td class=\"column-3\">4-10 ms<\/td><td class=\"column-4\">TDengine has much lower latency.<\/td>\n<\/tr>\n<tr class=\"row-5\">\n\t<td class=\"column-1\">Storage costs<\/td><td class=\"column-2\">Three replicas at 1.3 TB\/month<\/td><td class=\"column-3\">Two replicas at 87 GB\/month<\/td><td class=\"column-4\">Over 10x lower\u00a0storage costs for TDengine<\/td>\n<\/tr>\n<tr class=\"row-6\">\n\t<td class=\"column-1\">Stress testing<\/td><td class=\"column-2\">Additional nodes are needed for faster insertion speed<\/td><td class=\"column-3\">Stress testing on multiple Kubernetes nodes without degradation in performance.<\/td><td class=\"column-4\">TDengine Cluster supports 200,000 writes\/second.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<!-- #tablepress-33 from cache -->\n\n\n<h2 class=\"gb-headline gb-headline-2c0d2fb7 gb-headline-text\">TDengine Summary<\/h2>\n\n\n\n<h3 class=\"gb-headline gb-headline-16fdfa58 gb-headline-text\">Advantages<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Excellent time series database engine with better performance than <a href=\"https:\/\/tdengine.com\/compare-influxdb-tdengine\/\">InfluxDB<\/a>.<\/li>\n\n\n\n<li>Two-level&nbsp;storage architecture&nbsp;design (row storage and column storage) is optimal.<\/li>\n\n\n\n<li>Designed from scratch for IoT Big Data using novel concepts like <a href=\"https:\/\/tdengine.com\/supertable\/\">supertable<\/a>.<\/li>\n\n\n\n<li>Reduces storage and compute costs.<\/li>\n\n\n\n<li>Elastic expansion and contraction using the firstEP mechanism.<\/li>\n\n\n\n<li>Aggregate queries are lightning fast.<\/li>\n\n\n\n<li>Automatic time-based data expiration (TTL) and label mechanisms are very convenient to automate business requirements.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"gb-headline gb-headline-f4800147 gb-headline-text\">Needed Improvements<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Currently there are only basic monitoring indicators and these need to be improved. Performance checking also needs to look at logs, and write delays need to be monitored.<\/li>\n\n\n\n<li>Support for ecosystem tools needs to be improved to make administration and management easier.<\/li>\n\n\n\n<li>Upgrades to servers and clients should be consistent and automated\/packaged. Currently clients have to be updated in rolling batches, which is not very user friendly.<\/li>\n\n\n\n<li>Various types of error messages need to be further improved to be more user-friendly and easier to troubleshoot.<\/li>\n\n\n\n<li>The Go SDK does not support the prepare statement&nbsp;(Editor&#8217;s Note &#8211; the new version already supports it)<\/li>\n\n\n\n<li>Account isolation support needs to be improved. Currently, one cluster cannot support multiple accounts.<\/li>\n<\/ul>\n\n\n\n<p>In the end, whether it is MySQL, MongoDB, TiDB or TDengine, they are all excellent database products. But no database product is a silver bullet. The product that can adapt to, and meet business requirements, is ultimately the right solution.&nbsp;<\/p>\n\n\n\n<p>For Li Auto&#8217;s extremely high-performance and future scalability requirements, it is TDengine.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After reaching performance limits with MongoDB and TiDB, Li Auto chose TDengine for their high-performance IoT and Big Data platform.<\/p>\n","protected":false},"author":81,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[23,233,268],"tags":[],"ppma_author":[167],"class_list":["post-5691","post","type-post","status-publish","format-standard","hentry","category-case-studies","category-connected-cars","category-industrial-data"],"authors":[{"term_id":167,"user_id":81,"is_guest":0,"slug":"chait","display_name":"Chait Diwadkar","avatar_url":{"url":"https:\/\/tdengine.com\/wp-content\/uploads\/29.03-05-cdiwadkar.jpg","url2x":"https:\/\/tdengine.com\/wp-content\/uploads\/29.03-05-cdiwadkar.jpg"},"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/posts\/5691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/comments?post=5691"}],"version-history":[{"count":11,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/posts\/5691\/revisions"}],"predecessor-version":[{"id":29445,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/posts\/5691\/revisions\/29445"}],"wp:attachment":[{"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/media?parent=5691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/categories?post=5691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/tags?post=5691"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/ppma_author?post=5691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}