mysql1000并发单表插入看到系统资源使用上磁盘使用已经46%,但是插入500w的数据速度还是很快的10s,
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sdb 0.00 20769.00 0.50 10384.00 0.00 232.53 45.86 2.42 0.23 0.00 0.23 0.04 46.25
sda 0.00 3.00 0.00 2.00 0.00 0.02 20.00 0.00 0.25 0.00 0.25 0.25 0.05
avg-cpu: %user %nice %system %iowait %steal %idle
23.83 0.00 6.82 0.55 0.00 68.80
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sdb 0.00 21283.50 0.00 8991.00 0.00 191.45 43.61 1.73 0.19 0.00 0.19 0.05 42.10
sda 0.00 3.00 0.00 2.00 0.00 0.02 20.00 0.00 0.00 0.00 0.00 0.00 0.00
avg-cpu: %user %nice %system %iowait %steal %idle
24.22 0.00 7.18 0.52 0.00 68.09
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sdb 0.00 20635.00 1.00 8686.00 0.00 184.79 43.57 2.19 0.25 0.50 0.25 0.05 44.95
sda 0.00 3.50 0.50 3.50 0.00 0.03 15.00 0.00 0.00 0.00 0.00 0.00 0.00
SQL statistics:
queries performed:
read: 0
write: 469575
other: 0
total: 469575
transactions: 469575 (46320.18 per sec.)
queries: 469575 (46320.18 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 10.1376s
total number of events: 469575
Latency (ms):
min: 0.18
avg: 21.36
max: 2278.00
95th percentile: 102.97
sum: 10028688.01
Threads fairness:
events (avg/stddev): 469.5750/54.77
execution time (avg/stddev): 10.0287/0.02
下面测试mongodb 1000并发的插入,看到1000并发的情况下,吞吐上不如mysql,但是系统资源使用平稳,插入耗时较长,锁的时间较多
mongo client connection created with mongodb://perftest:perftest@xxx:37018/mongo_perf?waitQueueMultiple=100
[OVERALL], RunTime(ms), 332100.0
[OVERALL], Throughput(ops/sec), 15055.706112616681
[TOTAL_GCS_PS_Scavenge], Count, 18.0
[TOTAL_GC_TIME_PS_Scavenge], Time(ms), 37271.0
[TOTAL_GC_TIME_%_PS_Scavenge], Time(%), 11.222824450466726
[TOTAL_GCS_PS_MarkSweep], Count, 0.0
[TOTAL_GC_TIME_PS_MarkSweep], Time(ms), 0.0
[TOTAL_GC_TIME_%_PS_MarkSweep], Time(%), 0.0
[TOTAL_GCs], Count, 18.0
[TOTAL_GC_TIME], Time(ms), 37271.0
[TOTAL_GC_TIME_%], Time(%), 11.222824450466726
[READ-FAILED], Operations, 10165.0
[READ-FAILED], AverageLatency(us), 153589.34510575506
[READ-FAILED], MinLatency(us), 2029.0
[READ-FAILED], MaxLatency(us), 4.0370175E7
[READ-FAILED], 95thPercentileLatency(us), 44063.0
[READ-FAILED], 99thPercentileLatency(us), 676351.0
[CLEANUP], Operations, 1000.0
[CLEANUP], AverageLatency(us), 4.529
[CLEANUP], MinLatency(us), 0.0
[CLEANUP], MaxLatency(us), 4335.0
[CLEANUP], 95thPercentileLatency(us), 0.0
[CLEANUP], 99thPercentileLatency(us), 4.0
[INSERT], Operations, 4749937.0
[INSERT], AverageLatency(us), 62338.732124236594
[INSERT], MinLatency(us), 165.0
[INSERT], MaxLatency(us), 4.1779199E7
[INSERT], 95thPercentileLatency(us), 42047.0
[INSERT], 99thPercentileLatency(us), 96191.0
[INSERT], Return=OK, 4749937
[READ], Operations, 239898.0
[READ], AverageLatency(us), 57728.723365763784
[READ], MinLatency(us), 236.0
[READ], MaxLatency(us), 4.1713663E7
[READ], 95thPercentileLatency(us), 42015.0
[READ], 99thPercentileLatency(us), 97023.0
[READ], Return=OK, 239898
[READ], Return=NOT_FOUND, 10165
mongodb插入时间有1s之久
ns total read write 2017-11-02T16:00:54+08:00
mongo_perf.usertable 1068ms 50ms 1017ms
如果对于有很多表或集合的情况下,并且有大量的插入操作,mongodb还是比较适合的。