feat: improve performance with batch write
parent
b0d33586c5
commit
66241f6316
13
README.md
13
README.md
|
@ -1,5 +1,6 @@
|
|||
httpmq-rs
|
||||
===
|
||||
|
||||
[![Rust](https://github.com/hnlq715/httpmq-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/hnlq715/httpmq-rs/actions/workflows/rust.yml)
|
||||
|
||||
Benchmark
|
||||
|
@ -36,13 +37,11 @@ wrk -c 10 -t 2 -d 10s "http://127.0.0.1:1218/?name=xoyo&opt=put&data=aaaaaaaaaaa
|
|||
Running 10s test @ http://127.0.0.1:1218/?name=xoyo&opt=put&data=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
2 threads and 10 connections
|
||||
Thread Stats Avg Stdev Max +/- Stdev
|
||||
Latency 185.78us 163.52us 9.86ms 99.45%
|
||||
Req/Sec 26.82k 1.09k 29.17k 64.85%
|
||||
539029 requests in 10.10s, 76.08MB read
|
||||
Requests/sec: 53370.23
|
||||
Transfer/sec: 7.53MB
|
||||
|
||||
|
||||
Latency 139.45us 150.62us 9.51ms 99.34%
|
||||
Req/Sec 36.01k 1.56k 39.42k 71.78%
|
||||
723434 requests in 10.10s, 89.69MB read
|
||||
Requests/sec: 71629.07
|
||||
Transfer/sec: 8.88MB
|
||||
```
|
||||
|
||||
GET
|
||||
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 423 KiB After Width: | Height: | Size: 441 KiB |
|
@ -1,6 +1,6 @@
|
|||
use axum::{extract::Extension, extract::Query, http::StatusCode, response::IntoResponse};
|
||||
use once_cell::sync::OnceCell;
|
||||
use rocksdb::DB;
|
||||
use rocksdb::{WriteBatch, DB};
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
|
@ -88,9 +88,6 @@ fn httpmq_now_putpos(db: &rocksdb::DB, name: &String) -> Option<i32> {
|
|||
|
||||
debug!("newpos {} {:?}", newpos, metadata);
|
||||
|
||||
db.put(name.to_string() + ".putpos", newpos.to_string())
|
||||
.unwrap();
|
||||
|
||||
Some(newpos)
|
||||
}
|
||||
|
||||
|
@ -166,9 +163,13 @@ async fn kv_set(
|
|||
|
||||
if putpos > 0 {
|
||||
let queue_name = args.name.to_string() + &putpos.to_string();
|
||||
|
||||
let data = args.data.unwrap_or("".to_string());
|
||||
if data.len() > 0 {
|
||||
db.put(queue_name, data).unwrap();
|
||||
let mut batch = WriteBatch::default();
|
||||
batch.put(args.name.to_string() + ".putpos", putpos.to_string());
|
||||
batch.put(queue_name, data);
|
||||
db.write(batch).unwrap();
|
||||
return Ok(String::from("HTTPMQ_PUT_OK"));
|
||||
}
|
||||
Ok(String::from("HTTPMQ_PUT_NO_DATA"))
|
||||
|
|
Loading…
Reference in New Issue