如何增加REDIS CPU使用率

时间:2016-08-17 06:40:17

标签: node.js performance redis jmeter load-testing

您好我在 nodejs 中使用 redis 并尝试使用 jmeter 执行redis命令。

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

能否请你帮我制作redis最大cpu利用率

这是我的jmx文件

jmx file

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

|-- id: string (nullable = true)
 |-- sentences: array (nullable = true)
 |    |-- element: struct (containsNull = true)
 |    |    |-- sentence: string (nullable = true)
 |    |    |-- attributes: array (nullable = true)
 |    |    |    |-- element: struct (containsNull = true)
 |    |    |    |    |-- tokens: string (nullable = true)
 |    |    |    |    |-- ner: string (nullable = true)
 |    |    |    |    |-- pos: string (nullable = true)

1 个答案:

答案 0 :(得分:2)

您可以使用默认的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使用率。即使你的CPU使用率较低,我们也可以从redis配置文件中修改它。