在测试中与MySQL相比,mongodb连接时间极不稳定

我正在尝试进行一些测试,然后再从应用程序中完全从mySQL切换到mongoDB,并且在测试过程中,我发现mongoDB的连接时间极为不一致,这是我以前从未经历过的,并且好奇是否存在某些问题。配置中缺少。

我对AWS RDS实例和mongoDB Atlas实例运行了具有相同数据的比较插入测试,这是下面的结果。我可以清楚地看到好处,特别是在使用chatmongoDB迁移到mongoDB的情况下,但是我似乎无法弄清楚连接时间的变化。帮助堆栈! 执行示例代码

#json to be ingested
messages = json.load(open('messageJSON.json'))
client = MongoClient("mongodb+srv://<myremoteMongo>/?retryWrites=true&w=majority")
db = client.anychatdb
messageCollection = db.messages
for i in messages:
       messageCollection.insert_one(i)

结果如下:(

{
    "insert_msgs": {
        "mysql": {
            "run_1": {
                "total_time": "139.401s",
                "time_to_connect": "0.194s",
                "element_intervals": {
                    "1": "0.336s",
                    "10": "1.823s",
                    "50": "8.48s",
                    "100": "16.604s",
                    "200": "33.272s",
                    "300": "49.835s",
                    "400": "66.161s",
                    "500": "82.768s",
                    "600": "99.774s",
                    "700": "116.397s",
                    "800": "132.908s"
                }
            }
        },
        "mongodb": {
            "run_1": {
                "total_time": "40.608s",
                "time_to_connect": "18.328s",
                "element_intervals": {
                    "1": "0.396s",
                    "10": "0.615s",
                    "50": "1.696s",
                    "100": "2.982s",
                    "200": "5.54s",
                    "300": "8.121s",
                    "400": "10.72s",
                    "500": "13.32s",
                    "600": "16.054s",
                    "700": "18.624s",
                    "800": "21.27s"
                }
            },
            "run_2": {
                "total_time": "22.304s",
                "time_to_connect": "0.116s",
                "element_intervals": {
                    "1": "0.398s",
                    "10": "0.624s",
                    "50": "1.616s",
                    "100": "2.98s",
                    "200": "5.525s",
                    "300": "8.103s",
                    "400": "10.704s",
                    "500": "13.189s",
                    "600": "15.823s",
                    "700": "18.46s",
                    "800": "21.075s"
                }
            },
            "run_4": {
                 "total_time": "28.257s",
                "time_to_connect": "7.522s",
                "element_intervals": {
                    "1": "0.366s",
                    "10": "0.573s",
                    "50": "1.582s",
                    "100": "2.811s",
                    "200": "5.16s",
                    "300": "7.642s",
                    "400": "10.157s",
                    "500": "12.585s",
                    "600": "14.931s",
                    "700": "17.382s",
                    "800": "19.766s"
                }
            } 
        }
    }
}