Redis主節點記憶體佔用過高

來源:互聯網
上載者:User

標籤:received   cli   active   eve   模式   串連   客戶   命令   roc   

0. 基本情況

Redis採用叢集模式,560個主節點,主從比為1:1,單台機器上為16個節點。info memory觀察到主節點A單個Redis記憶體used_memory_rss_human為9.2G(設定的maxmemory_human為6G)超過最大值設定。

1.查看用戶端串連情況

[[email protected] A ~]# redis-cli -p 9001 info clients

# Clients

connected_clients:4705

client_longest_output_list:204928

client_biggest_input_buf:0

blocked_clients:0

通過client_longest_output_list發現有大量的輸出排隊,進一步觀察所有的用戶端均存在這個情況。

 

在A機器上刷用戶端輸出list:

 

CLIENT_A:9001# Clients

client_longest_output_list:491335

CLIENT_A:9002# Clients

client_longest_output_list:520840

CLIENT_A:9003# Clients

client_longest_output_list:486498

CLIENT_A:9004# Clients

client_longest_output_list:485387

CLIENT_A:9005# Clients

client_longest_output_list:480000

CLIENT_A:9006# Clients

client_longest_output_list:537211

CLIENT_A:9007# Clients

client_longest_output_list:487594

CLIENT_A:9008# Clients

client_longest_output_list:490037

CLIENT_A:9009# Clients

client_longest_output_list:478734

CLIENT_A:9010# Clients

client_longest_output_list:524717

CLIENT_A:9011# Clients

client_longest_output_list:487200

CLIENT_A:9012# Clients

client_longest_output_list:491687

CLIENT_A:9013# Clients

client_longest_output_list:483900

CLIENT_A:9014# Clients

client_longest_output_list:524557

CLIENT_A:9015# Clients

client_longest_output_list:497967

CLIENT_A:9016# Clients

client_longest_output_list:484250

 

2.輸出記憶體佔用不為0 的內容

 [[email protected] A redis-node]# redis-cli -p 9001 client list |grep -v "omem=0"

id=843 addr=client_B:53475 fd=2248 name= age=582784 idle=0 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=456078 omem=7446059139 events=rw cmd=replconf

 

通過cmd可知是主從同步佔用大量輸出記憶體

3.檢查統計值

 

有問題Client A的從client_B

[[email protected] 9001]# redis-cli -p 9001

127.0.0.1:9001> info stats

# Stats

total_connections_received:2

total_commands_processed:25

instantaneous_ops_per_sec:0

total_net_input_bytes:1280055129

total_net_output_bytes:36461

instantaneous_input_kbps:192.22

instantaneous_output_kbps:0.00

rejected_connections:0

 

正常的機器C的從Client D

[[email protected] D redis-node]# redis-cli -p 9001

127.0.0.1:9001> info Stats

# Stats

total_connections_received:10

total_commands_processed:23220212769

instantaneous_ops_per_sec:18281

total_net_input_bytes:3405817622262

total_net_output_bytes:59530419

instantaneous_input_kbps:2882.54

instantaneous_output_kbps:0.03

rejected_connections:0

輸入速度差了10倍,其他配置均一樣,懷疑是網路問題。

 

4.檢查網路時延

 

機器A的從client_B

[[email protected] redis-node]# traceroute client_B

traceroute to client_B (client_B), 30 hops max, 60 byte packets

 1  *.*.*.254   0.752 ms  0.809 ms  0.900 ms

 2  *.*.*.133  2.164 ms  2.170 ms  2.157 ms

 3  * * *

 4  * * *

 5  *.*.*.2  163.542 ms  163.940 ms  164.181 ms

 6  client_B (client_B)  160.995 ms  156.202 ms  158.603 ms

 

Clinet C的從Client D

[[email protected] ~]# traceroute Client D

traceroute to Client D (Client D), 30 hops max, 60 byte packets

 1  *.*.*.254   0.732 ms  0.799 ms  0.897 ms

 2  *.*.*.133   3.147 ms  3.182 ms  3.168 ms

 3  * * *

 4  * * *

 5  *.*.*.2   5.537 ms  5.788 ms  5.961 ms

 6  Client D (Client D)  1.953 ms  1.960 ms  1.956 ms

 

測試機器A到機器D效能

[[email protected] 42 9001]#  traceroute Client D

traceroute to Client D (Client D), 30 hops max, 60 byte packets

 1  *.*.*.254 (10.180.128.254)  0.738 ms  0.800 ms  0.889 ms

 2  *.*.*.133 (10.180.176.133)  2.156 ms  2.190 ms  2.177 ms

 3  * * *

 4  * * *

 5  *.*.*.2   5.768 ms  5.942 ms  6.114 ms

 6  Client D (Client D)  1.940 ms  1.964 ms  1.948 ms

 

說明是機器A到client_B網路有問題

 

5.解決辦法

更換從的機器到client_B到clinet E

 

啟動後機器A上9001 記憶體使用量情況

127.0.0.1:9001> info memory

# Memory

used_memory:2771776520

used_memory_human:2.58G

used_memory_rss:3403390976

used_memory_rss_human:3.17G

used_memory_peak:18154232496

used_memory_peak_human:16.91G

used_memory_peak_perc:15.27%

used_memory_overhead:758586508

used_memory_startup:8105584

used_memory_dataset:2013190012

used_memory_dataset_perc:72.84%

total_system_memory:540783263744

total_system_memory_human:503.64G

used_memory_lua:37888

used_memory_lua_human:37.00K

maxmemory:6442450944

maxmemory_human:6.00G

maxmemory_policy:volatile-ttl

mem_fragmentation_ratio:1.23

mem_allocator:jemalloc-4.0.3

active_defrag_running:0

lazyfree_pending_objects:0

127.0.0.1:9001>

6.解決後觀察

Client E記憶體同步情況

 

127.0.0.1:9001> info stats

# Stats

total_connections_received:37

total_commands_processed:5318696

instantaneous_ops_per_sec:19310

total_net_input_bytes:1711079396

total_net_output_bytes:4954958

instantaneous_input_kbps:2967.88

instantaneous_output_kbps:70.17

rejected_connections:0

sync_full:0

 

修改後機器A上的9001 輸出

[[email protected] redis-node]# redis-cli -p 9001 info  clients

# Clients

connected_clients:4695

client_longest_output_list:0

client_biggest_input_buf:0

blocked_clients:

 

 

7.總結:

在redis設定同樣而記憶體使用量不同時,應先查看info命令對比正常機器的輸出不同,優先關注Stats的輸出情況以及本地的redis.log日誌

 

Redis主節點記憶體佔用過高

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.