0.0
No commit activity in last 3 years
No release in over 3 years
Ruby gem to test the speed of a Memcached server and verify that it's working correctly.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
~> 4.9.3

Runtime

>= 0
>= 0
 Project Readme

MemcacheCheck

This gem is intended to help find problems with Memcached servers. MemcacheCheck runs a series of set and get commands against a Memcached server and validates the data returned. It also returns the benchmark time that it takes to run the get and set commands to help find slow responding servers.

Installation

Add this line to your application's Gemfile:

gem 'memcache_check'

And then execute:

$ bundle

Or install it yourself as:

$ gem install memcache_check

Usage

There are now 2 primary methods to use the gem. The original single server benchmark and the new group benchmark.

Single

Create an instance of MemcacheCheck::Checker and pass in an argument of the server's IP address as a string. If you don't pass an IP address in it will default to localhost. You can optionally pass in a second argument of the port number if you are running memcached on a non-standard port.

Once you have an instance you simply run the start method and pass it the number of key value pairs you want to test against the server. If you don't pass a value in it will default to 50.

The start method returns an array of 3 numbers:

- Number of passing set/get pairs
- Number of failing set/get pairs
- Benchmark time to run the test

example.rb

require 'memcache_check'

memcache_check = MemcacheCheck::Checker.new('127.0.0.1')
passes, fails, time = memcache_check.start(500)

puts "Number of passes: #{passes}"
puts "Number of failures: #{fails}"
puts "Total time: #{time} seconds"

Running on my local machine this produces:

Number of passes: 500
Number of failures: 0
Total time: 0.369204 seconds

Group

Pass a list of hostnames and/or IP addresses to MemcacheCheck::Checker.group_benchmark. It runs 100 set and get checks against each hostname and returns an array of Server objects once the benchmark has completed.

The Server attributes available are:

- hostname   (string)
- port       (string)
- passes     (fixnum)
- fails      (fixnum)
- time       (Benchmark::Tms)

example.rb

require 'memcache_check'

memcache_check = MemcacheCheck::Checker.group_benchmark('127.0.0.1', 'localhost', '127.0.0.1')

memcache_check.each do |server|
  puts "Server: #{server.hostname}"
  puts "Number of passes: #{server.passes}"
  puts "Number of failures: #{server.fails}"
  puts "Total time: #{server.time.real.round(3)}"
  puts
end

Running on my local machine this produces:

Server: 127.0.0.1
Number of passes: 100
Number of failures: 0
Total time: 0.074

Server: localhost
Number of passes: 100
Number of failures: 0
Total time: 0.066


Server: 127.0.0.1
Number of passes: 100
Number of failures: 0
Total time: 0.082

Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request