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

How to Access a div from another website using jQuery

I have a question. How can I call a div from another website using JavaScript? Here is the page: Now, I want to call the <div id="testa"> in another page. The other page is called Otherpage.html: jQuery(function($){ $(&ap ...

Why isn't the unit test passing when it clearly should be?

I am encountering an issue with testing a simple function that I have created. Despite the fact that the function works correctly in practice, it is not being tested properly... Explanation of how my function operates (While it functions as intended, the ...

The confirm() function shows up before the background on a blank layout

I'm facing an issue where whenever my confirm() function pops up, the alert box displays correctly but then the background turns blank. I've tried various solutions like moving the entire if statement to the bottom of the page or at the end of th ...

chosen selection from AngularJS dropdown

I'm really struggling with something. Currently, I am working on a web app using AngularJS where I have created a table displaying database results. Each row in the table contains a select item loaded with a model. However, I am unsure how to mark a ...

Comparing npm install --save versus npm install --save-dev

Hey everyone, I've been using npm install -g to globally install node modules/packages, but I'm a bit confused about the --save and --save-dev options. I tried looking it up on Google, but I'm still not entirely sure. Can you guys help clar ...

JS: Issue with iterating over objects

Within my JavaScript code, there exists an object named box_object with the following structure: ({ id:"3", text:"this is a box object", connection_parent:["1", "2"], connection_child:["5", "6"], connectiondata_child:{ 0:{id:"5", ...

Encountering difficulty importing TypeScript files dynamically within a Deno executable

When attempting to import a file from aws in an exe using its public link based on user input, I am facing difficulties For example, I generated my exe with the command below deno compile --allow-all main.ts Users execute this exe using commands like ./e ...

Enhancing JSON Objects in AngularJS with Custom Properties and Calculations

Hello, I'm still getting the hang of angularjs and could use some guidance. I have a Rest service that provides data on saleItems when a get request is made, as shown below: saleItems = [ { "id": 236, "variant": "Oval Holder", "mrp": "6 ...

Calculate the total sum of input values using jQuery

Here is the HTML I've been working with: I am trying to create a script where one textbox will display the total amount, and another textbox will display the following data: "name": [{ "id": 3, "qty": 2 }, { "id": 4, "qty": 5 }] Here's ...

Struggling to fetch information from API through Express in NodeJS with MongoDB, currently loading

I am in the process of creating a Rest API using Node.js, Express, and MongoDB. Currently, I am running it on my local host:3000. When I attempt to restart and run the server, I utilize the route http://localhost:3000/drinks To send HTTP requests, I use P ...

What is the best way to transform HeadersInit into an Object<string,string> data type?

In short, I am faced with the task of converting the headers of a RequestInit into a format that another library can comprehend. This particular library requires the headers to be in the format of Object<string, string>. Initially, I attempted someth ...

Ways to identify when a file download has finished with the help of javascript

let pageUrl = "GPGeneration_Credit.ashx?UniqueID=" + __uniqueId + "&supplierID=" + supplierID + "&CreditID=" + OrderIds; window.open(pageUrl); // Want to check if the file download is complete and then refresh the page location.r ...

What are the steps to recursively transform a JavaScript object?

I am currently working on recursively transforming a JavaScript object, but I have encountered an issue. The problem is: if any object key has exactly two properties - 'label' and 'value', then the value should change to the label only ...

In JavaScript, a variable's value can be assigned to another variable using the variable

I have a collection of predetermined variables. I dynamically assign a value to another variable, which ends up representing the name of one of the predefined variables. This allows me to easily determine which set variable to use on a particular section o ...

Updating the "title" attribute dynamically using jQuery in real time

I have a span that displays data in a tooltip every second, fetched from the server: <span class="info tooltip" title="{dynamic content}"></span> To show the tooltip, I'm using the tooltipsy plugin: $('.tooltip').tooltipsy({ ...

Successfully resolved: Inability to dynamically adjust button color according to its state

Currently I am working on a feature where a button changes color when it is disabled, but also has a custom color when enabled. Here is the code snippet I am using: Despite setting blue text for the button, it remains blue even after becoming disabled. Ho ...

Harmonizing Express (Passport) with AngularJS Routing

I have been working on developing a MEAN-stack application and I have reached the point of setting up user authentication. Following this tutorial: After implementing it into my project, I noticed that it works partially. The issue is that I can only acce ...

What is the best way to discover all available matches?

By utilizing this code snippet, I am able to locate text between specific start and end words. However, the search process stops after the first pair is found. Is there a way to identify all matches? const file = fs.readFileSync('./history.txt', ...

The result of calling addEventListener is undefined

My issue lies with the addEventListener function, as it is not working correctly. I've created a function that requires an event listener to track scrolling and then execute a callback function. window.addEventListener("scroll", checkPosition); Unf ...

Retrieve HTML content from Vuetify components without displaying it on the webpage

I have a project where I need to retrieve the HTML code from various Vuetify components. Instead of just as a HTML string, I actually need it as a DOM element that can be easily added to the body. This is necessary for me to be able to utilize these compon ...