Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8918837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:51:04+00:00 2026-06-15T05:51:04+00:00

I created a small Java application (with Spring Data) to test MongoDB performance with

  • 0

I created a small Java application (with Spring Data) to test MongoDB performance with geospatial queries .

public class MongoThread {

public static void main(String[] args) throws Exception {

    if(args.length != 1) {
        System.out.println("Usage: MongoThread <nb_thread>");
        System.exit(0);
    }

    int nbThread = Integer.parseInt(args[0]);

    ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringMongoConfigStandalone.class);
    MongoOperations db = (MongoOperations) ctx.getBean("mongoTemplate");

    for (int x=0; x<nbThread; x++) {
        double lat = Math.random() * 60;
        double lng = Math.random() * 60;
        double radius = 3000 + 50 * Math.random();
        MyThread t = new MyThread("Thread #" + x, db, lat, lng, radius);
        t.start();
    }

    //create1MEntries(db);
}

private static void create1MEntries(MongoOperations db) {
    if (!db.getCollectionNames().contains("Item")) {
        db.createCollection("Item");
    }
    db.indexOps(Item.class).ensureIndex(new GeospatialIndex("loc"));
    for(int i=0; i<1000000; i++) {
        Item item = new Item();
        item.setName("item" + i);
        item.setLoc(new double[]{Math.random() * 180, Math.random() * 180});
        db.save(item, "Item");
    }
}
}

class MyThread extends Thread {

String name;
MongoOperations db;
double lat, lng, radius;

public MonThread (String name, MongoOperations db, double lat, double lng, double radius) {
    this.name = name;
    this.db = db;
    this.lat = lat;
    this.lng = lng;
    this.radius = radius;
}

public void run() {
    long t1 = Calendar.getInstance().getTimeInMillis();
    List<Item> items = db.find(new Query(Criteria.where("loc")
            .near(new Point(lat,lng)).maxDistance(radius/111.12)).limit(100), Item.class, "Item");
    System.out.println(name + " - " + items.size() + " results found around " + radius + " of (" + lat + "," + lng + ")");
    long t2 = Calendar.getInstance().getTimeInMillis();
    System.out.println(name + " - " + (t2-t1) + "ms");
}
}

public class Item {
    @Id
    private String id;
    private String name;
    private double[] loc;
}

After running the tests multiple times to load data in memory, here are the results I get:

  • On my dev computer (Win7 64 bits, i7 860 @2.8 Ghz, RAM 8GB 1066Mhz): For 100 threads, I get all responses in about 500 ms (between 450 ms and 550 ms)

  • On my server (hosted by OVH: Debian 6.0 64 bits, i3 2130 2×2(HT) 3.4GHz, RAM 16GB 1333Mhz): For 100 threads, I get all responses in about 1700 ms (between 1600 ms and 1900 ms)

I am not a hardware neither Linux specialist but I was expecting this server to do better than my Windows computer (or at least as good).
I read on several forums that MongoDB was really faster on Linux and that important hardware features were (in that order): RAM, CPU (but Mongo does not use multiple cores) and hard drives.

I increased the max open files (using ulimit -n 99999) because I read that it can slow down MongoDB but it had no effect on the results.

Do you have an idea where the bottleneck come from?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:51:06+00:00Added an answer on June 15, 2026 at 5:51 am

    I don’t think this is a linux vs windows issue. I mean that i3 processor is pretty low end compared to the beast that i7 is on your windows machine.

    If you really want to compare performance between the two operating systems, I recommend to get your setup running on identical hardware..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a small Java application to automatically test some expressions for a
i implemented a small web application to create Rss feeds in java(spring mvc) i
I'm writing a small demo application in Java using Spring, that needs to have
I'm developing bunch of relatively small Spring based java web-application. I'm mostly using annotations
I have created a small web application in java. And now I want to
I created a command line interface on a small java application I created for
I have created a small Java application in which there is some code that
I created a small WPF desktop application. I am thinking about how to make
I have created a small chatting application in C#, and started as a Console
I've created a small script to test creating my own help based powershell and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.