Simple performance question

Kevin Smith ksmith at basho.com
Tue Feb 23 10:47:57 EST 2010


Victor - 

You're running into the slow performance of anonymous Javascript functions in the current release of Riak. For now, anonymous functions should only be used for prototyping and development on smallish amounts of data. You make your job run faster by converting the anonymous function to a named one. The conversion process is pretty painless:

1. Create a named function for your reduce phase and store it in a file ending in ".js". For example:

function my_reduce (values, a) {
  minKey = 'ZZZZ'; minTask = null;
  for(i = 0; i < values.length; ++i) {
    val = values[i]
    if(val.scheduled < minKey){
      minKey = val.scheduled;
      minTask = val;
    }
  }
  return [minTask];
 }

2. Uncomment the js_source_dir configuration entry and point it at a directory where you saved the file from step #1.

3. Restart Riak so it picks up the configuration change.

4. Modify your job description to use the named function.

5. If you need to edit the function or add/remove others you can use the riak-admin tool to reload the Javascript by issuing the command 'riak-admin reload_js'.

--Kevin

On Feb 23, 2010, at 10:05 AM, Victor 'Zverok' Shepelev wrote:

> Hi all.
> 
> Trying to test riak performance, I've stored 10'000 values
> (JSON-encoded objects) in one bucket, then trying map-reduce request
> to this bucket.
> 
> map phase is just "Riak.mapValuesJson"
> 
> reduce phase is like
> ---
>    function(values, a){
>        minKey = 'ZZZZ'; minTask = null;
>        for(i = 0; i < values.length; ++i){
>            val = values[i]
>            if(val.scheduled < minKey){
>                minKey = val.scheduled;
>                minTask = val;
>            }
>        }
>        return [minTask];
>    }
> ---
> 
> It's like just: find task with minimal "scheduled" field.
> 
> Then, on bucket with 10'000 values, I have this request performing
> ~1min (through Unix time) on Celeron 2.6GHz 1Gb.
> Is this result expected or am I doing something wrong?
> 
> Also, sometimes I obtain just {"error":"timeout"} instead of result.
> Is this expected?
> 
> Thanks.
> 
> V.
> 
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com




More information about the riak-users mailing list