如何增加REDIS CPU使用率

嗨,我在nodejs中使用redis ,并尝试使用Jmeter执行redis命令。

CPU使用率不超过5%,我也试图增加负载,然后CPU使用率也不超过5%。 当我试图使用默认基准testing,然后CPU使用率达到50%。

你能帮我做redis最大的CPU利用率

这是我的jmx文件

jmx文件

这是我的nodejs程序var express = require('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!'); }); 

您可以使用默认的redis查询来了解CPU使用情况

试试这个查询来检查你的redis的cpu使用情况

  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> 

从这里你可以得到确切的redis CPU使用率。 即使你有更less的CPU使用率,我们可以从redisconfiguration文件修改它。