【问题标题】:How to benchmark Redis all operations at once如何一次对 Redis 的所有操作进行基准测试
【发布时间】:2016-12-24 22:13:41
【问题描述】:

当我尝试使用默认基准对 redis 进行基准测试时,所有操作都在一个接一个地执行,有什么方法可以并行执行所有操作?

【问题讨论】:

    标签: testing redis jmeter performance-testing benchmarking


    【解决方案1】:

    我在nodejs & express中使用过redis api,并使用jmeter进行了测试。

    这是我的代码,

        var express = require('express');
        var app = express();
        
        var redis = require("redis"),
        client = redis.createClient(6379,"10.96.82.175");
        
        app.get('/', function (req, res) {    
                  res.send("HEY  Nodejs runnning on 10.96.82.175:4000");
        });
    
        app.put('/set/:arg1/:arg2', function (req, res) {
        
              client.set( req.params.arg1,req.params.arg2,function (err, reply) {
                if (reply==null)
                {
                  res.send("null");
                }
                else {
                  res.send(reply.toString());
                }
        
              });
        });
        
        
        app.get('/get/:arg1', function (req, res) {
              client.get( req.params.arg1,function (err, reply) {
        
                if (reply==null)
                {
                  res.send("null");
                }
                else {
                  res.send(reply.toString());
                }
        
              });
        });
        
        
        
        
        
        
        app.get('/incr/:arg1', function (req, res) {
              client.incr(req.params.arg1, function (err, reply) {
                if (reply==null)
                {
                  res.send("null");
                }
                else {
                  res.send(reply.toString());
                }
        
                  //console.log(reply.toString());
              });
        });
        
        
        
        
        
        app.put('/lpush/:arg1/:arg2', function (req, res) {
          client.lpush(req.params.arg1,req.params.arg2, function (err, reply) {
            if (reply==null)
            {
              res.send("null");
            }
            else {
              res.send(reply.toString());
            }
        
                  //console.log(reply.toString());
              });
        });
        
        
        
        app.get('/lpop/:arg1', function (req, res) {
          client.lpop(req.params.arg1, function (err, reply) {
        
            if (reply==null)
            {
              res.send("null");
            }
            else {
              res.send(reply.toString());
            }
              });
        });
        
        
        
        app.put('/sadd/:arg1/:arg2', function (req, res) {
          client.sadd(req.params.arg1,req.params.arg2, function (err, reply) {
            if (reply==null)
            {
              res.send("null");
            }
            else {
              res.send(reply.toString());
            }
                  //console.log(reply.toString());
              });
        });
        
        
        
        
        app.get('/spop/:arg1', function (req, res) {
          client.spop(req.params.arg1,1, function (err, reply) {
        
            if (reply==null)
            {
              res.send("null");
            }
            else {
              res.send(reply.toString());
            }
                  //console.log(reply.toString());
              });
        });
        
        
        app.put('/zadd/:arg1/:arg2/:arg3', function (req, res) {
          client.zadd(req.params.arg1,req.params.arg2,req.params.arg3,function (err, reply) {
            if (reply==null)
            {
              res.send("null");
            }
            else {
              res.send(reply.toString());
            }
                  //console.log(reply.toString());
              });
        });
        
        app.put('/hset/:arg1/:arg2/:arg3', function (req, res) {
              client.hset(req.params.arg1,req.params.arg2,req.params.arg3,function (err, reply) {
                if (reply==null)
                {
                  res.send("null");
                }
                else {
                  res.send(reply.toString());
                }
                  //console.log(reply.toString());
              });
        });
        
        app.get('/hget/:arg1/:arg2', function (req, res) {
        
              client.hget(req.params.arg1,req.params.arg2,function (err, reply) {
        
                if (reply==null)
                {
                  res.send("null");
                }
                else {
                  res.send(reply.toString());
                }
                  //console.log(reply);
              });
        });
        
        app.listen(4000, function () {
        
          console.log('Example app listening on port 4000!');
        });
    

    这是我的 jmx 文件

    JMX FILE LINK

    【讨论】:

      猜你喜欢
      • 2017-09-18
      • 1970-01-01
      • 1970-01-01
      • 2012-01-02
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多