Skip to content

Instantly share code, notes, and snippets.

@otoolep
Created November 8, 2021 17:27
Show Gist options
  • Save otoolep/f2f650dc24a9408ddaed2d08bde6ac89 to your computer and use it in GitHub Desktop.
Save otoolep/f2f650dc24a9408ddaed2d08bde6ac89 to your computer and use it in GitHub Desktop.
rqlite query performance example
Start node:
$ rqlited data
Create and insert some data:
$ curl -XPOST 'localhost:4001/db/execute?pretty&timings' -H "Content-Type: application/json" -d '[
> "CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT, age INTEGER)"
> ]'
{
"results": [
{
"time": 0.000154929
}
],
"time": 0.010213863
}
$ curl -XPOST 'localhost:4001/db/execute?pretty&timings' -H "Content-Type: application/json" -d '[
> "INSERT INTO foo(name, age) VALUES(\"fiona\", 20)"
> ]'
{
"results": [
{
"last_insert_id": 1,
"rows_affected": 1,
"time": 0.000072691
}
],
"time": 0.016080437
}
(do the above a few time)
Then run two instances of rqbench *in parallel*:
$ ./rqbench -n 100000 -p "/db/query" 'SELECT COUNT(*) FROM foo'
Test target: http://localhost:4001/db/query
Total duration: 23.965082044s
Requests/sec: 4172.74
Statements/sec: 4172.74
./rqbench -n 100000 -p "/db/query" 'SELECT COUNT(*) FROM foo'
Test target: http://localhost:4001/db/query
Total duration: 24.019902206s
Requests/sec: 4163.21
Statements/sec: 4163.21
I see thousands of queries serviced per second. Check out the source of rqbench.
https://github.com/rqlite/rqlite/tree/master/cmd/rqbench
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment