jsonmongodbrestjmeterjongo

Comparing save methods through load test between Jongo driver, Java MongoDB driver and MongoRepository


In my diploma thesis I developed REST API for select/save operations between client and database. Data will be post from sensors as JSON and stored in MongoDB . We chose three different technologies for storing: Jongo driver 1.3.0, Java MongoDB driver 3.4.0 and MongoRepository from Spring (with Jackson FasterXML). After implemenetation we started with load tests through JMeter. Test case had these parameters:

threads - 100, 250, 500, 1000

ramp up period - 10 seconds

loop count - 30

We are supposed that drivers will be more effective than MongoRepository, but in case of 1000 threads MongoRepository load 400 requests per second and drivers could not process all of requests. So MongoRepository can store rapidly fast. Can anyone says why MongoRepository is more effective ?

EDIT:

MongoRepository look like this:

@Repository
public interface EndPointsMongoRepository extends 
MongoRepository<EndPointsDataControllerEntity, String> {
}

Method deseralize json to entity :

    private EndPointsDataControllerEntity parseDataFromJson(String json) {

    ObjectMapper mapper = new ObjectMapper();
    EndPointsDataControllerEntity controller = null;
    try {
        controller = mapper.readValue(json, EndPointsDataControllerEntity.class);
    } catch(JsonParseException ex){
        LOGGER.warn(" JsonParseException with message :" + ex.getMessage());
    } catch(JsonMappingException ex){
        LOGGER.warn("JsonMappingException with message :" + ex.getMessage());
    } catch(IOException ex){
        LOGGER.warn("IOException with message :" + ex.getMessage());
    }
    LOGGER.info("Id controller: " + controller.getIdController());
    return controller;
}

Then I only save data.

Java MongoDB driver implementation:

public void saveUnstructuredMeasuredData(String json) {

    LOGGER.info("Data saved to database by second way: \n" + json);
    com.mongodb.client.MongoCollection<Document> collection = getMongoClient().getCollection(UNSTRUCTURED_DATA);
    Document objectFromJson = Document.parse(json);

    objectFromJson.put(TIMESTAMP_MEASURE, createTimeMeasureAsTimestamp(objectFromJson));

    collection.insertOne(objectFromJson);
}

And Jongo:

public void saveUnstructuredMeasuredDataStraightWithShell(String json) {

    LOGGER.info("Data saved to database by third way: \n" + json);
    Jongo jongo = new Jongo(getMongoDB());

    MongoCollection measuredData = jongo.getCollection(MEASURED_DATA);
    measuredData.insert(json);
}

Solution

  • Jongo is not a driver, it uses one. Basically, the one you mentioned next - that is the "official" driver. And the third is even the interface, that has two different implementations - which one's yours?

    So, see, there's kind of conceptual mess you've just created. And to answer your question, you need to get into implementation details for each case.

    I can just presume that, being enterprise-grade and quite mature framework, Spring has more effecient concurrent implementation, something with connection/worker pools or stuff like that.