ReadySet项目开发环境搭建与运行指南

ReadySet项目开发环境搭建与运行指南

readyset ReadySet is a transparent database cache for Postgres & MySQL that gives you the performance and scalability of an in-memory key-value store without requiring that you rewrite your app or manually handle cache invalidation. Based on the Noria project from MIT. Built using Rust. 🚀 readyset 项目地址: https://gitcode.com/gh_mirrors/re/readyset

前言

ReadySet是一个基于Rust开发的高性能数据库缓存层,能够显著提升数据库查询性能。本文将详细介绍如何搭建ReadySet的开发环境,包括依赖安装、项目编译、服务启动以及测试执行等关键步骤。

开发环境准备

系统依赖安装

ReadySet运行需要以下系统依赖:

  • clang编译器
  • libclang开发库
  • OpenSSL开发库
  • LZ4压缩库
  • 基础构建工具
macOS系统安装
brew install lz4
brew install openssl@1.1
Ubuntu系统安装
sudo apt update && sudo apt install -y build-essential libssl-dev pkg-config llvm clang liblz4-dev cmake

Rust工具链安装

ReadySet完全使用Rust编写,因此需要安装Rust工具链:

curl https://sh.rustup.rs -sSf | sh

安装完成后,请确保使用项目rust-toolchain.toml文件中指定的Rust版本。

运行时依赖

ReadySet需要与上游数据库(MySQL/PostgreSQL)和Consul服务协同工作。

本地开发环境

为简化本地开发,可以使用Docker Compose快速启动所有依赖服务:

cp docker-compose.override.yml.example docker-compose.override.yml
docker-compose up -d
完整部署环境

在生产环境中,ReadySet需要:

  1. 一个可用的MySQL或PostgreSQL数据库实例
  2. Consul服务用于领导者选举

注意:Consul会持久化每个部署的数据。使用相同的部署名称会保留之前安装的查询。

编译与运行ReadySet

ReadySet服务端

首先编译并运行ReadySet服务端:

cargo run --bin readyset-server --release -- --upstream-db-url <upstream-url> --deployment <deployment name>

如果使用Docker Compose提供的数据库:

  • MySQL: mysql://root:readyset@127.1/readyset
  • PostgreSQL: postgresql://root:readyset@127.1/readyset

ReadySet适配器

然后运行适配器二进制文件,适配器将与具有相同部署名称的服务端通信。

MySQL适配器
cargo run --bin readyset --release -- --database-type mysql --upstream-db-url mysql://root:readyset@127.1/readyset --allow-unauthenticated-connections --address 0.0.0.0:3307 --deployment <deployment name> --prometheus-metrics
PostgreSQL适配器
cargo run --bin readyset --release -- --database-type postgresql --upstream-db-url postgresql://postgres:readyset@127.1/readyset --allow-unauthenticated-connections --address 0.0.0.0:5433 --deployment <deployment name> --prometheus-metrics

适配器将在address参数指定的地址监听连接。

prometheus-metrics标志会在适配器中暴露一个HTTP端点用于查询指标,可通过HTTP GET请求访问,例如:curl -X GET 127.0.0.1:6034/metrics

项目测试

运行项目测试:

cargo test --skip integration_serial

测试注意事项

  1. 某些测试不能与其他测试并行运行,这些测试通常位于以_serial为后缀的文件中
  2. 运行整个包的测试可能会因包含串行测试而失败
  3. 测试可能需要增加文件描述符限制:ulimit -Sn 65535

性能优化建议

在性能关键场景下运行ReadySet时,请确保使用--release标志进行编译,以获得最佳性能。

结语

通过本文的指导,您应该已经成功搭建了ReadySet的开发环境,并了解了如何运行服务和执行测试。ReadySet作为一个数据库缓存层,能够显著提升查询性能,特别是在读密集型的应用场景中。在实际开发过程中,建议根据具体需求调整配置参数以获得最佳性能表现。

readyset ReadySet is a transparent database cache for Postgres & MySQL that gives you the performance and scalability of an in-memory key-value store without requiring that you rewrite your app or manually handle cache invalidation. Based on the Noria project from MIT. Built using Rust. 🚀 readyset 项目地址: https://gitcode.com/gh_mirrors/re/readyset

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

花淑云Nell

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值