《任春韶2023RustChinaConf-ceresdb rust 生产实践.pptx》由会员分享,可在线阅读,更多相关《任春韶2023RustChinaConf-ceresdb rust 生产实践.pptx(22页珍藏版)》请在三个皮匠报告上搜索。
1、CeresDB Rust 生产实践生产实践任春韶CeresDB 核心开发者蚂蚁集团技术专家l CeresDB 介绍介绍l Rust 生产实践生产实践-Tokio Preemption-Future Cancellation目录CeresDB 历程2018.022018.102019.022020.112021.9自研存储引擎1.0.0 版本发布查询性能优化Prometheus 协议支持基于 InfluxDB 单机引擎研发分布式方案OpenTSDB 协议内存时序数据库存储计算分离架构分级存储永久代CeresDB 开源2022.62023.3开源版本 CeresDB 开始研发2023.61.2.2
2、 版本发布优化了写入性能优化了分布式方案CeresDB 目标解决时间线高基数问题解决时间线高基数问题能高效处理好 APM 型时序数据同时能高效处理好高基数时间线场景提供原生分布式方案提供原生分布式方案大规模部署提供高可用、高可靠的服务支持水平扩容支持高效的分布式查询-Tokio Preemption-Future CancellationRust 生产实践生产实践 Tokio为什么使用 Tokio?1.业界使用最广泛,测试齐全。2.Tokio 支持 async/await,提供了高效的异步锁、异步队列等。3.Tokio 社区支持好。生产实践 Tokio Rust future preempti
3、onhttps:/docs.rs/tokio/latest/tokio/#cpu-bound-tasks-and-blocking-codeHowever,this kind of swapping can only happen at.awaitpoints,so code that spends a long time without reaching an.awaitwill prevent other tasks from running.生产实践 Future循环RunReturnhttps:/rust-lang.github.io/async-book/04_pinning/01_
4、chapter.html#why-pinninghttps:/doc.rust-lang.org/beta/unstable-book/language-features/generators.html生产实践 Async lockReq0Req1Req2Memory cachehttps:/docs.rs/tokio/1.28.2/tokio/sync/struct.Mutex.html#which-kind-of-mutex-should-you-use生产实践 Async lockruntime.spawn(task0)runtime.spawn(task1)runtime.spawn(
5、task2)生产实践 Async lock runtime.spawn(task0)runtime.spawn(task1)runtime.spawn(task2)生产实践 Async lock 总结:Async lock:按需使用,如果是纯内存计算的时候,使用 blocking mutex 比较好。生产实践 Mixed workloadWriteReadCompactRuntimes问题:CeresDB 监控写 OSS 耗时高,OSS 监控看耗时低。生产实践 Mixed workloadruntime.spawn(task0)runtime.spawn(task1)runtime.spawn
6、(task2)runtime.spawn(task3)生产实践 Mixed workloadcpu_runtime.spawn(task0)cpu_runtime.spawn(task1)cpu_runtime.spawn(task2)cpu_runtime.spawn(task3)生产实践 Preemption总结:Mixed workload:碰到混合负载的时候,把 CPU 密集型任务隔离出去会得到比较好的效果。相关 Blog:1.https:/tokio.rs/blog/2020-04-preemption2.https:/ kind of swapping can only happe
7、n at.awaitpoints,so code that spends a long time without reaching an.awaitwill prevent other tasks from running.生产实践 Cancellation生产实践 Cancellationtry_join_all!(a,b,c)https:/docs.rs/futures/latest/futures/future/fn.try_join_all.html生产实践 Cancellationtry_join_all!(a,b,c)join_all!(a,b,c)https:/ spawn生产实践 CancellationAsync workgroup 在 roadmap 中也有提到。https:/rust-lang.github.io/wg-async/vision/roadmap/scopes.htmlFAQGitHubGitHub:https:/ you!