Running sysbench based benchmarks against Cassandra
#!/usr/bin/env sysbench
function event()
local cassandra = require "cassandra"
local peer= assert(cassandra.new {
host = "172.17.0.2",
port = 9042,
keyspace = "test"
})
assert(peer:connect())
assert(peer:execute("select * from user"))
peer:close()
end
A couple of comments about the script:
- 172.17.0.2 is the IP address of the Cassandra node I want to connect to. In my case, this is another container, but be sure to change this as needed if you want to reproduce this test (or refer to this gist to see how I ran mine).
- For the script to work, the Cluster must have a 'test' keyspace with a 'user' table on it (as you can see from the query, the table structure does not matter here).
telecaster:sysbench-docker fipar$ docker run -v ~/src/:/src/ --name=sb -it severalnines/sysbench bash -c 'luarocks install lua-cassandra --local; luarocks install luasocket --local; /src/tmp/benchmark1.lua run' Warning: The directory '/root/.cache/luarocks' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing /usr/local/lib/luarocks/rocks/luarocks/2.4.3-1/bin/luarocks with sudo, you may want sudo's -H flag. Installing https://luarocks.org/lua-cassandra-1.2.3-0.rockspec ...snip... Installing https://luarocks.org/luasocket-3.0rc1-2.src.rock ...snip... sysbench 1.0.13 (using bundled LuaJIT 2.1.0-beta2) Running the test with following options: Number of threads: 1 Initializing random number generator from current time Initializing worker threads... Threads started! General statistics: total time: 10.0017s total number of events: 2792 Latency (ms): min: 2.17 avg: 3.57 max: 48.12 95th percentile: 4.65 sum: 9958.60 Threads fairness: events (avg/stddev): 2792.0000/0.00 execution time (avg/stddev): 9.9586/0.00You can see I am installing the required Lua modules when starting the container. If a benchmark will be executed several times (which is usually the case) a better approach would be to further customize the Dockerfile to include the necessary modules. I have not done that in the PR though because I think that would bloat the existing image. You can also see that I'm making my machine's src directory available on the container via the -v ~/src/:/src/. That's why I can then execute the script from /src/ on the container. Be sure to adjust this as needed to point to a directory tree where the lua script can be found on your machine. In conclusion, if you have benchmarking needs and have not considered sysbench, don't be put off if your database of choice is not listed as supported: as long as there's a Lua driver for it there's a good chance that you will be able to use sysbench for the task!
On this page
Share this
Share this
More resources
Learn more about Pythian by reading the following blogs and articles.
Docker Orientation
Docker Orientation
Jul 1, 2020 12:00:00 AM
9
min read
Monitor Cassandra using Zabbix
Monitor Cassandra using Zabbix
Nov 7, 2016 12:00:00 AM
9
min read
Interesting happenstance when installing Ansible dependencies in a MySQL Docker container
Interesting happenstance when installing Ansible dependencies in a MySQL Docker container
Jun 25, 2018 12:00:00 AM
5
min read
Ready to unlock value from your data?
With Pythian, you can accomplish your data transformation goals and more.