0

I wanted to migrate our servers today, but I couldn't since on the new (larger) server MongoDB was very slow for a specific collection. First of all, here are the specs.

Old server:

Digital Ocean 80$ Instance
RAM: 4GB
vCPUs: 4 (I can't find the GHZ)

New server:

Switch Engines c1.large Instance
RAM: 8GB
vCPUs: 8 (again, I can't find the GHZ)

Both servers have enough SSD space.

On the new server I get: enter image description here

while I'm retrieving documents from this one specific collection. Afterwards still the mongodb keeps the 43% memory occupied. On the old server, mongo uses constantly around 8% memory and there are no CPU spikes when I request documents from the problematic collection.

What I'm doing to retrieve the things from the collection is:

Iterator<CompilerCacheEntry> found = ds()
        .find(CompilerCacheEntry.class).filter("hash", hash)

while (found.hasNext()) {...

where ds is from org.mongodb.morphia.Datastore; and the filter is implemented like this:

public Query<T> filter(String condition, Object value) {
    String[] parts = condition.trim().split(" ");
    if(parts.length >= 1 && parts.length <= 6) {
        String prop = parts[0].trim();
        FilterOperator op = parts.length == 2?this.translate(parts[1]):FilterOperator.EQUAL;
        this.add(new Criteria[]{new FieldCriteria(this, prop, op, value, this.validateName, this.validateType)});
        return this;
    } else {
        throw new IllegalArgumentException("\'" + condition + "\' is not a legal filter condition");
    }
}

What's also curious, is that the mongodb before migration was 30GB and now it's 3GB, but I read that's just because mongo cleans up upon migration.

So I'm left with general confusion and some questions:

  • How can it be, that on the stronger machine mongo is slower?
  • Why is mongo hogging 43% memory?
  • It looks like mongo is only using one cpu, might this be the problem?
  • Is the problem memory related or cpu related or none of those?
  • What's the problem with mongo, respectively my code? Why does mongo have such a hard time retrieving this object?
  • Is my collection too large for my memory?

Here are parts of the collection stats for reference:

>db.compilercache.stats()
{
    "ns" : "taskbase.compilercache",
    "count" : 21191,
    "size" : 4592895563,
    "avgObjSize" : 216738,
    "storageSize" : 1814052864,
    "capped" : false,

In case you need more information, please let me know. Thanks a lot in advance!

3
  • Have you used the exact same configuration of MongoDB in both servers? Jul 21, 2016 at 11:52
  • 1
    the settings in /etc/mongod.conf are the same, but the versions are different. Old Server runs Mongo v3.0.8 while the new runs on mongo v3.2.8. I'll try to pin the installation to 3.0.8 give you an update whether this helped
    – bersling
    Jul 21, 2016 at 13:16
  • with mongo v3.0.8 it's fast again... thanks for the hint
    – bersling
    Jul 21, 2016 at 14:01

0

You must log in to answer this question.

Browse other questions tagged .