简体   繁体   English

如何增加REDIS CPU使用率

[英]How to increase REDIS CPU usage

Hi i am using redis in nodejs and trying to execute the redis commands using jmeter . 嗨,我使用Redis的中和的NodeJS试图执行使用JMeter的 Redis的命令。

The cpu usage exceeding not more than 5% and I tried to increase the load then too the cpu usage not exceeding 5% . cpu使用率不超过5%,我尝试增加负载,然后cpu使用率也不超过5%。 when i tried to test using default benchmark then cpu usage reaching 50% . 当我尝试使用默认基准测试时,CPU使用率达到50%。

Can you please help me to make redis maximum cpu utilization 您能帮我提高Redis的CPU使用率吗

this is my jmx file 这是我的jmx文件

jmx file JMX文件

this is my nodejs program var express = require('express'); 这是我的nodejs程序var express = require('express'); var app = express(); var app = express();

var redis = require("redis"),
//client = redis.createClient(6379,"10.96.82.163");
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!');
});

You can use the default redis querys to know CPU usage 您可以使用默认的redis查询来了解CPU使用率

Try this query to check you cpu usage of redis 试试这个查询来检查你的CPU使用redis

         redis-cli INFO


redis> INFO
# Server
redis_version:999.999.999
redis_git_sha1:ceaf58df
redis_git_dirty:1
redis_build_id:a5eeeb464ee54856
redis_mode:standalone
os:Linux 4.1.5-x86_64-linode61 x86_64
arch_bits:32
multiplexing_api:epoll
gcc_version:4.4.1
process_id:21798
run_id:2569bb7433bfe013c2627edf62d9bf21eaf8a010
tcp_port:6379
uptime_in_seconds:14657590
uptime_in_days:169
hz:10
lru_clock:11800083
config_file:/etc/redis/6379.conf

# Clients
connected_clients:8
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:7452400
used_memory_human:7.11M
used_memory_rss:10383360
used_memory_rss_human:9.90M
used_memory_peak:8370272
used_memory_peak_human:7.98M
total_system_memory:4142215168
total_system_memory_human:3.86G
used_memory_lua:24576
used_memory_lua_human:24.00K
maxmemory:3221225472
maxmemory_human:3.00G
maxmemory_policy:unknown
mem_fragmentation_ratio:1.39
mem_allocator:jemalloc-3.6.0
lazyfree_pending_objects:0

# Persistence
loading:0
rdb_changes_since_last_save:523
rdb_bgsave_in_progress:0
rdb_last_save_time:1471417783
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok

# Stats
total_connections_received:5182
total_commands_processed:88168233
instantaneous_ops_per_sec:14
total_net_input_bytes:6664442907
total_net_output_bytes:8760305877
instantaneous_input_kbps:1.12
instantaneous_output_kbps:0.07
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:96738
evicted_keys:0
keyspace_hits:22092056
keyspace_misses:6172004
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:536
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:11952.80
used_cpu_user:10508.02
used_cpu_sys_children:247.59
used_cpu_user_children:5335.29

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=2917,expires=3,avg_ttl=84137679668
redis> 

From this you can get exact redis CPU usage. 由此,您可以获得确切的redis CPU使用率。 Even you have less CPU usage we can modify it from redis configuration file. 即使您的CPU使用量较少,我们也可以从Redis配置文件中对其进行修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM