Performance of write requests?

Stephan Maka stephan at spaceboyz.net
Mon May 10 16:43:35 EDT 2010


(Sorry for breaking the thread, I just subscribed.)

I am experiencing very low performance as well. I'm attaching a small
benchmark script. Writing 32 KB chunks yields a much higher rate first,
then disk activity starts after about 4 seconds and throughput is
trashed to about 30-50 put/s. This is on a standard 60 MB/s 12ms
drive.

I've tested both innostore_riak and riak_kv_bitcask_backend. The
latter shows /slightly/ improved performance. What's odd is that there's
always a lot of data read, despite the script not reading data.

Are there any special Linux knobs or secret backend parameters?


Stephan
-------------- next part --------------
-module(riak_bench).

-export([run/1]).

-define(BUCKET, <<"benchmark">>).
-record(state, {last_print = make_timestamp(),
		i = 0,
		pending = 0,
		threshold = 1,
		done = 0, last_done = 0,
		client, 
		doc = gen_doc(32 * 1024)}).

run(Threshold) ->
    {ok, Client} = riak:client_connect('riak at 127.0.0.1'),
    loop(#state{client = Client,
		threshold = Threshold}).

gen_doc(Size) ->
    list_to_binary([<<(I rem 256)>>
			|| I <- lists:seq(1, Size)]).

loop(#state{i = I,
	    pending = Pending,
	    threshold = Threshold,
	    client = Client,
	    doc = Doc} = State)
  when Pending < Threshold ->
    J = I + 1,
    Caller = self(),
    spawn_link(fun() ->
		       K = list_to_binary(io_lib:format("test-~B", [J])),
		       RObj = riak_object:new(?BUCKET, K, Doc),
		       ok = Client:put(RObj, 1, 1),
		       Caller ! done
	       end),
    loop(State#state{i = J,
		     pending = Pending + 1});
loop(#state{pending = Pending, last_print = LastPrint,
	    done = Done, last_done = LastDone} = State) ->
    receive
	done ->
	    Now = make_timestamp(),
	    NewDone = Done + 1,
	    if
		Now >= LastPrint + 1.0 ->
		    io:format("~B done, ~.1f put/s~n", [NewDone, (NewDone - LastDone) / (Now - LastPrint)]),
		    loop(State#state{pending = Pending - 1,
				     done = NewDone,
				     last_print = Now,
				     last_done = NewDone});
		true ->
		    loop(State#state{pending = Pending - 1,
				     done = NewDone})
	    end
    end.

make_timestamp() ->
    {MS, S, SS} = now(),
    MS * 1000000 + S + SS / 1000000.


More information about the riak-users mailing list