1. 程式人生 > >1000萬個key的效能測試

1000萬個key的效能測試

測試機器:16G記憶體 

測試前:

程式碼:

public static void main(String[] args) {
      Jedis jedis = new Jedis("localhost");
      jedis.auth("123456");

      System.out.println(jedis.ping());
      Pipeline pipeline = jedis.pipelined();
      long start = System.currentTimeMillis();
      for (int i = 8000000; i < 10000000; i++) {
         pipeline.set("MSG_READ_STATUS_1609147_" + i, "1");
      }
      List<Object> results = pipeline.syncAndReturnAll();
      long end = System.currentTimeMillis();
      System.out.println("Pipelined SET: " + ((end - start)/1000.0) + " seconds");

//    long start = System.currentTimeMillis();
//    for (int i = 0; i < 1000; i++) {
//       jedis.get("MSG_REA_STATU_16091_" + i);
//    }
//
//    long end = System.currentTimeMillis();
//    System.out.println("Pipelined SET: " + ((end - start)/1000.0) + " seconds");
      jedis.disconnect();



   }

100萬100萬的set,不敢一下子全set萬,怕機器廢了。耗時沒截圖,大概幾s吧

dbsize可檢視key多少

info檢視記憶體詳情

顯示。1000w個key大約佔記憶體827M。其實也是因為我們的value值較小,就是1.

效能測試:

for迴圈獲取1000個key的時間:

 

 

如何清理掉所有的key:flushall

 

另,附windows下安裝redis:

https://blog.csdn.net/u012343297/article/details/78839063

下載地址:

https://github.com/ServiceStack/redis-windows