What is the best configuration to use for successful MapReduce queries in Riak?

While working on a nodejs application with riak / riak-js, I encountered the following issue:

Executing this request

db.mapreduce
  .add('logs')
  .run();

successfully retrieves all 155.000 items stored in the bucket logs along with their IDs:

[ 'logs', '1GXtBX2LvXpcPeeR89IuipRUFmB' ],
[ 'logs', '63vL86NZ96JptsHifW8JDgRjiCv' ],
[ 'logs', 'NfseTamulBjwVOenbeWoMSNRZnr' ],
[ 'logs', 'VzNouzHc7B7bSzvNeI1xoQ5ih8J' ],
[ 'logs', 'UBM1IDcbZkMW4iRWdvo4W7zp6dc' ],
[ 'logs', 'FtNhPxaay4XI9qfh4Cf9LFO1Oai' ],
....

If I provide a map function and only select a few items from the bucket logs

db.mapreduce
  .add([['logs', 'SUgJ2fhfgyR2WE87n7IVHyBi4C9'], ['logs', 'EMtywD1UFnsq9rNRuINLzDsHdh2'], ['logs', 'ZXPh5ws8mOdASQFEtLDk8CBRn8t']])
  .map( function(v) {return ["asd"]; } )
  .run();

everything works fine and the expected output is returned as follows:

[ 'asd', 'asd', 'asd' ]

However, if I try to map all items (approximately 155.000 small JSON documents) in the "logs" bucket using:

db.mapreduce    
  .add('logs')  
  .map( function(v) {return ["asd"]; } )    
  .run();

I only receive errors:

{ [Error: [object Object]] message: '[object Object]', statusCode: 500 }

What could be causing this error? The Error object doesn't provide any useful information.

Update: The Riak console displays the following error multiple times:

[notice] JS call failed: All VMs are busy.

After increasing map_js_vm_count in Riak's app.config to 36, the error changes to:

[error] Pipe worker startup failed: fitting was gone before startup

For more information, visit: Basho Labs Riak Driver riak-js

Answer №1

A Response from Bryan at basho.com:

Hello, Cornelius. Can you provide more details about your Riak configuration? I am particularly interested in the number of nodes in your cluster and the ring_creation_size specified in your app.config file.

If, for instance, you are using the default setup {ring_creation_size, 64} on a development cluster with only one node, it is likely that the behavior you are experiencing is due to this configuration. With 155,000 items, all 64 vnodes will be functional.

In the first scenario, without increasing map_js_vm_count, the 64 vnodes have limited Javascript VMs to work with, leading to potential timeouts. This would result in the "All VMs are busy" log message being triggered.

In the second case, even after raising map_js_vm_count, 36 Javascript VMs may not be able to process all 155,000 items within the query timeout period. The "fitting was gone before startup" log message indicates that the pipe running the query closed prematurely while data was still being sent to the vnodes.

You may not encounter these issues in simple cases without map functions as they do not require interaction with Javascript VMs. In such instances, objects are not retrieved from disk, reducing resource conflicts.

To address these challenges, adjusting the ring_creation_size lower and increasing the query timeout can be beneficial. A reduction to 16 or even 8 on a single-node cluster will reduce competition for Javascript VMs during map function processing. Extending the query timeout (as an argument to the 'run' function) will allow more time for queries to complete before shutdown, especially if processing is slow.

Furthermore, rewriting your map function in Erlang could improve performance and alleviate VM contention. However, I acknowledge that transitioning to Erlang may pose difficulties during early-stage development.

Hope this helps, Bryan

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Understanding the intricacies of JavaScript function calls often results in unexpected null returns

I currently have a code that is able to run and collect data using an AJAX library. My goal is to allow users to add their own functions to the library and execute them, similar to $.get. It may be a bit difficult to fully explain what I am trying to achie ...

Blend express router by chaining the (.route) method with other HTTP methods like (.get, .post, etc) to create

Here is my code structure: let router = require( 'express' ).Router(); Later on, I define my routes like this: router .route( '/' ) .get( listMiddleware ); router .route( '/:id' ) .get( getOneByIdMiddleware ...

Organizing angular shapes in alphabetical order

My drop down arrow has elements that are not properly sorted. I have been attempting to use the orderBy angular filter but have encountered some challenges. Upon further investigation, it seems the issue arises because the content I need displayed is neste ...

Angular.js - organizing a list of items and preserving the outcome

Here is a compilation of randomly arranged items: <ul class="one" drag-drop="page.items"> <li ng-repeat='item in page.items|orderBy:page.random as result'> <img ng-src="http://placecage.com/{{item.id*100}}/{{item.id*100}}"& ...

Choosing the Laravel 6 option for editing via AJAX: A step-by-step guide

I am looking to update a user who resides in a specific state within a country. The country and state fields are dropdown select options, with a relationship established between them and the user. The state field is populated based on the selected country. ...

The button event is currently only targeting the initial class. (Jquery)

I am having an issue where only the first instance of the saveBtn class is being saved into local storage when clicked. Can anyone provide some assistance with this? Here is the HTML: <div class="hour-container" id="8am"> & ...

The module ~/assets/images/flags/undefined.png could not be found in the directory

When I use the img tag with a dynamic address filled using require, it works well in the component. However, when I try to write a test for it, an error is thrown. console.error Error: Configuration error: Could not locate module ~/assets/ima ...

Retrieve the callback arguments using sinon.spy within a JavaScript promise

During my test with mocha and sinon, I encountered an issue where I couldn't retrieve a callback value from inside a promise scope of an HTTP-request due to the asynchronous nature of promises. It seems that by the time sinon.spy checks on the callbac ...

The order in which JavaScript is being executed is being reversed

function checkForDuplicate(center, email) { $.ajax({ type: "POST", url: "../staff/staffDA.php", data: "funId=-4&center=" + center + "&email=" + email, success: function (data) { if (data.split('| ...

Generate a flexible JSON array in VB.NET

Looking to generate a flexible array that can be converted into a JSON array for visualization with Morris charts. The usual approach in VB.NET is as follows: Dim xArray(2) xArray(0) = New With {Key .TradingDay = "Day1", .Seller1 = 1500, .Seller2 = 160 ...

The animation speed of the jQuery hashchange event is set to zero, causing the animation

I'm facing an issue with jQuery where my animation inside a hashchange event is not smooth; it happens instantly when triggered. I'm looking for a way to make the animation smoother. jQuery( document ).ready(function() { jQuery(window).on(&a ...

How to use React hooks to flip an array

Is it possible to efficiently swap two items in an array using JavaScript? If we are dealing with a boolean, one could achieve this by: const [isTrue, setIsTrue] = useState(false); setIsTrue(!isTrue); However, what if we have an array? // Let's ...

Having difficulty uploading an image to Facebook through the graph API

I have a requirement to upload a photo to Facebook using the Javascript SDK, but I am experiencing some difficulties: Firstly, FB.login(function (response) { if (response.authResponse) { va ...

Unable to display JSON results in a tabular format

After successfully implementing the AJAX method in jQuery, I am able to receive a response. However, I am encountering difficulties when trying to display the arrays in a table format. success:function(resp){ var json =JSON.parse(JSON.stringif ...

Caution: Attempting to access a non-existent 'sequelize' property within a circular dependency in the module exports

Issue Nodemon server.js [nodemon] 2.0.15 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node server.js` Warning: connect.session() MemoryStore is not designe ...

Encountering an error when attempting to iterate over an undefined property using an API

I am trying to fetch all classes and their assignments from Google Classroom. I successfully used Google's example code for listing the classes, but had to write my own code for listing the assignments. While the code runs as expected and lists the as ...

How to send props from a Vue.js component tag in an HTML file

I'm facing an issue with passing props from the HTML to the JavaScript code and then down to a Vue component. Here's a snippet of my index.html file: <div id="js-group-discounts"> <div class="form-group required"> <datepick ...

Nuxt.js static pages with relative URLs

I am currently working on developing static pages with Nuxt.js (MPA). After executing the generate command, I noticed that all the URLs in the <nuxt-link> tag start from the root directory, specifically /. For instance, my project structure looks lik ...

Why isn't the JavaScript if statement working properly when checking the length?

Below is an if statement that I have devised: var TotalMoney=0; var Orbs=0; if (TotalMoney.length==2) { Orbs+=1; } The intention behind this code snippet is to increase the value of "Orbs" by 1 when the digit length of "TotalMoney" equals 2. However, it& ...

Switch positions of two objects in JavaScript

Check out the code snippet below: MyObject.prototype.doIt = function() { let a = this.obj1; let b = this.obj2; } I need to find a way to switch the values of this.obj1 and this.obj2, making obj1 take on the value of obj2 and vice versa. Pleas ...