Spring + MongoDB performance drops by half after few thousand of documents

292 views Asked by At

Have a service that starting from a clean database is able to insert documents at a rate of 70/second, after a few thousands i see the performance drop by half.

Documents follow a structure similar to http://schema.org/Product and their http://schema.org/Offer

I'm using Spring + MongoTempate and MongoDB 3.4 with a single index on each offer own id and seller id:

    db.getCollection('ProductFullDetails').createIndex({'offers.offers.seller.sellerId': 1, 'offers.offers.sellerProductId': 1});
1

There are 1 answers

0
Joel Mata On

The problem was caused by the lack of an index.

Though this might sound obvious, in reality it took a careful look in order to find the optimal set of indexes to use as too much was also the cause for issues.

Used both the mongostat and the Mongo Compass tools for this task. Among several others, the most amazing functionality is the Compass "slowest operations" found under the database performance analytics.