0

I have a meteor app that's hosted on Galaxy with the database on mLab.

The meteor method to update documents works fine if the document is small, but if its larger than a certain size, the galaxy CPU usage goes up to 100% and the container becomes unhealthy.

Meteor APM reports that the database update is taking <400ms, while "computation" (directly prior to update) is taking 80 000+ ms.

Here's a simplified example of the code.

The collection is declared and assigned a schema in one file.

trips.js

const Trips = new Mongo.Collection('trips');
//schema is declared and attached

export {Trips}

The methods are declared in another file.

Methods.js

import {Trips} from '../trips';

Meteor.methods({

    'updateTrip' (tripId, trip){
        check(tripId, String);
        check(trip, Object);

        Trips.update({
             _id: tripId
        },{
           $set: {
             field1: trip.field1,
             field2: trip.field2,
             field3: trip.field3
           }
        });
    }       
});

In some cases the fields are objects with large objects nested within.

I'm new to Meteor and MongoDB, and was not the original developer for this project, so I'm wondering if there's a bug in this code that could be causing the 100% CPU usage and long delays.

sdeak
  • 1
  • 2
  • Welcome to Stack Overflow, and welcome to Meteor and Mongodb. Have you tried doing updates with smaller objects to see how the performance changes? – Mikkel Jan 17 '19 at 20:14
  • @Mikkel Thanks! and yes I have, with much smaller objects the "computation" time is <300ms and the CPU usage only spikes to ~15%, so it seems to be directly correlated – sdeak Jan 17 '19 at 20:29
  • ok, this is critical information in terms of solving your issue... what is the "certain size" where this starts to be a problem? Perhaps your document size is too large, and you need to consider breaking it up into smaller pieces, although that is pre-empting your response on what the threshold of poor performance is – Mikkel Jan 18 '19 at 03:51

0 Answers0