【发布时间】:2020-12-05 00:06:12
【问题描述】:
我有 2 台服务器,一台 AWS 和一台 Microsoft azure VM,它们都是 8 核 32 GB。
我在两台服务器上都使用以下脚本来检查 MongoDB 中的插入速度。 在 AWS 实例上,我使用 localhost 和 LAN IP 平均得到 3 秒。 在 Microsoft azure 上,我用 localhost 得到 3 秒,但在 LAN IP 上得到 30 秒。 我检查了两台服务器上的网络速度(大约 1.73 Gbits/sec),几乎相同。
-
两者都有标准 SSD。
-
MongoDB 版本相同。
-
两者都有wiredTiger存储引擎。
唯一的区别是 Azure 应用程序在负载均衡器上,而 AWS 应用程序不在。
if($_REQUEST['mongo']=='localserver'){
$mongoip = "localhost";
}elseif($_REQUEST['mongo']=='mongoserver'){
$mongoip = "x.x.x.x";/* LAN IP of dedicated mongo server */
}
$a = "mongo_speed_check";
$mongo_dbname = "speed";
try {
$maa = new MongoClient("mongodb://{$mongoip}/{$mongo_dbname}");
$dbnew1 = $maa->selectDB($mongo_dbname);
} catch ( MongoConnectionException $e ) {
print_r($e);
}
$time_start = microtime(true);
for ($i = 0; $i < 10000; $i++){
$dbnew1->$a->insert(array('i' =>$i,"field{$i}" => $i * 2));
}
$time_end = microtime(true);
$execution_time = ($time_end - $time_start);
echo '<br><b>Total Execution Time:</b> '.$execution_time.' seconds';
有人可以告诉我我在这里缺少什么吗?
谢谢!
【问题讨论】:
-
将第一个插入与其他插入分开计时。
标签: mongodb azure php-5.6 azure-load-balancer