mongo 单机性能测试
来源:互联网 发布:fire 7 tablet 知乎 编辑:程序博客网 时间:2024/05/16 12:34
各位小伙伴,今天我们来用java压一下单节点,同机器的mongo。
2.7 GHz Intel Core i5
8 GB 1867 MHz DDR3
核总数:2
import com.mongodb.MongoClient;import com.mongodb.client.MongoCollection;import com.mongodb.client.MongoDatabase;import org.bson.Document;/** * Created by tarner on 17/9/19. */public class Application { public static void main(String[] args) throws Exception { MongoClient mongoClient = new MongoClient("127.0.0.1"); MongoDatabase test = mongoClient.getDatabase("test"); MongoCollection<Document> test1 = test.getCollection("test1"); long beginTime = System.currentTimeMillis(); //写100万数据 //test1// int i = 0;// while (i < 1000000) {// test1.insertOne(new Document("a" + i, "va" + i));// i++;// } //qps=10,416 //test2// int j = 0;// int i = 0;// while (i < 1000) {//// ArrayList<Document> list = new ArrayList<>(10000);//// for (int k = 0; k < 10000; k++) {// list.add(new Document("a" + j, "va" + j));// j++;//// }// i++;//// test1.insertMany(list);// }// qps = 111,111 //test3// CompletableFuture<Void> v1 = CompletableFuture.runAsync(() -> {// int j = 0;// int i = 0;// while (i < 500) {//// ArrayList<Document> list = new ArrayList<>();//// for (int k = 0; k < 1000; k++) {// list.add(new Document("a" + j, "va" + j));// j++;//// }// i++;//// test1.insertMany(list);// }// });//// CompletableFuture<Void> v2 = CompletableFuture.runAsync(() -> {// int j = 0;// int i = 500;// while (i < 1000) {//// ArrayList<Document> list = new ArrayList<>();//// for (int k = 0; k < 1000; k++) {// list.add(new Document("a" + j, "va" + j));// j++;//// }// i++;//// test1.insertMany(list);// }// });////////// v1.join();// v2.join(); //qps=156,250 long endTime = System.currentTimeMillis(); long userTime = endTime - beginTime; System.out.println(userTime); mongoClient.close(); }}
在这里,我一共进行了三次试验,都是写入1,000,000条数据。只计算写入mongo的耗时。
第一次试验,是每次写1条数据,写1000000,从结果来看qps=10416不是很高,个人觉得这里因为是同步的,如果多建立一些线程,会有提高,不过因为线程切换,估计也好不到哪里去。
第二次试验,每次写1000条,写1000次。从结果qps=111,111。已经快了十倍。
第三次试验,两个线程,每次1000条,每个线程500次。从结果来看qps=156,250。又提示了不少。
阅读全文
0 0
- mongo 单机性能测试
- Redis 单机性能测试
- Mongo性能测试-python脚本
- 单机数据库性能测试总结
- 单机与网络性能测试
- kafka 单机读写性能测试
- mongo性能测试demo 代码正确运行
- redis(单机读取数据性能测试)
- redis 写操作性能测试 (单机)
- kafka-0.10版本单机性能测试
- openfire 登陆 mysql转mongo性能测试及性能提升
- redis 集群性能测试以及与单机性能对比
- openfire mysql 转mongo 注册行为性能测试及其他
- spark+kafka+Elasticsearch单机环境的部署和性能测试
- Mongo Database 性能优化
- Mongo性能检查
- mongo性能优化
- ycsb测试mongo笔记
- Spring AOP 配置文字简述。(完善中)
- 十年建站老司机带你十分钟搭建网站
- iOS 添加fmdb 报错
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- jsp页面中,JSTL El表达式字符串比较常用方法
- mongo 单机性能测试
- 前端中的几个position
- spark实现join功能
- 4.3 自定义控件 之 继承ViewGroup实现标签云
- 《The Docker Book》NodeJS Dockerfile
- 1100: 求组合数(函数专题)
- Spring 注解学习笔记
- 使用Json设置网页省份与城市的级联查询
- [问题解决]Android中getDrawable和getColor过时的替代方法