관리 메뉴

개발이야기

[ Database ] redis info 사용법 (Python 예제) 본문

DB & Infra/Database

[ Database ] redis info 사용법 (Python 예제)

안성주지몬 2019. 5. 16. 00:00

이번 포스팅에서는 redis info 명령에 대해서 알아보도록 하겠습니다.

 

< redis-cli >

 

info memory

 

 

< python >

 

- Python redis info 예제 코드 - 메모리 확인 

import redis

def connect_redis():

    try:

        conn = redis.StrictRedis(host=redis_info['host'], port=redis_info['port'], db=redis_info['db'])



    except Exception as e:

        print("DB connection error: ", e)

    return conn





def info_redis():

    conn = connect_redis()

    result = conn.info(section='memory')

    print(result)



info_redis()

 

 

- 결과

{'used_memory': 591262928, 'used_memory_human': '563.87M', 'used_memory_rss': 385761280, 'used_memory_rss_human': '367.89M', 'used_memory_peak': 4051490928, 'used_memory_peak_human': '3.77G', 'used_memory_peak_perc': '14.59%', 'used_memory_overhead': 3118450, 'used_memory_startup': 790960, 'used_memory_dataset': 588144478, 'used_memory_dataset_perc': '99.61%', 'allocator_allocated': 591320624, 'allocator_active': 593371136, 'allocator_resident': 631226368, 'total_system_memory': 8372948992, 'total_system_memory_human': '7.80G', 'used_memory_lua': 52224, 'used_memory_lua_human': '51.00K', 'used_memory_scripts': 1688, 'used_memory_scripts_human': '1.65K', 'number_of_cached_scripts': 3, 'maxmemory': 0, 'maxmemory_human': '0B', 'maxmemory_policy': 'noeviction', 'allocator_frag_ratio': 1.0, 'allocator_frag_bytes': 2050512, 'allocator_rss_ratio': 1.06, 'allocator_rss_bytes': 37855232, 'rss_overhead_ratio': 0.61, 'rss_overhead_bytes': 18446744073464086528, 'mem_fragmentation_ratio': 0.65, 'mem_fragmentation_bytes': 18446744073504111888, 'mem_not_counted_for_evict': 0, 'mem_replication_backlog': 0, 'mem_clients_slaves': 0, 'mem_clients_normal': 557106, 'mem_aof_buffer': 0, 'mem_allocator': 'jemalloc-5.1.0', 'active_defrag_running': 0, 'lazyfree_pending_objects': 0}

 

used_memory

Redis의 메모리 사용량 (바이트 단위)

 

used_memory_peak

메모리 최대 사용량 

 

 

레퍼런스

[1] https://redis.io/commands/INFO

[2] https://zetawiki.com/wiki/Redis_INFO_MEMORY

[3] https://zetawiki.com/wiki/Redis_INFO

Comments