【发布时间】:2016-08-18 11:59:03
【问题描述】:
您好,我在 nodejs 中使用 redis 并尝试使用 jmeter 执行 redis 命令。
cpu 使用率不超过 5%,我尝试增加负载,然后 cpu 使用率不超过 5%。 当我尝试使用默认基准测试时,cpu 使用率达到 50%。
你能帮我把redis的cpu利用率最大化吗
这是我的 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.io/topics/benchmarks
-
我正在使用 redis-stat 进行监控,而对于负载测试,我正在使用 jmeter
-
你能给你看看 JMeter 测试计划吗?澄清你是如何进行负载测试的?多少线程? GUI / 非 GUI ....
标签: node.js performance redis jmeter load-testing