SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
REDIS
charsyam@naver.com
장애관리
First of All.
Single Thread
Single Thread 의
의미
Don‘t execute
Long Tasks.
O(n) Commands
O(n) Commands
KEYS
FLUSHALL/FLUSHDB
DEL big size of collections
KEYS *
di = dictGetSafeIterator(c->db->dict);
allkeys = (pattern[0] == '*' && pattern[1] == '0');
while((de = dictNext(di)) != NULL) {
……
stringmatchlen(pattern,plen,key,sdslen(key),0)
}
FlushAll
Cache Item Count Time
Memcache 1,000,000 1~2ms
Redis 1,000,000 1000ms(1
second)
FlushAll-Redis
for (i = 0; i < ht->size && ht->used > 0; i++) {
dictEntry *he, *nextHe;
if ((he = ht->table[i]) == NULL) continue;
while(he) {
nextHe = he->next;
dictFreeKey(d, he);
dictFreeVal(d, he);
zfree(he);
ht->used--;
he = nextHe;
}
}
FlushAll-Memcache
if (exptime > 0)
settings.oldest_live = realtime(exptime) -
1;
else /* exptime == 0 */
settings.oldest_live = current_time - 1;
FlushAll-Memcache
if (settings.oldest_live != 0 &&
settings.oldest_live <= current_time &&
it->time <= settings.oldest_live) {
do_item_unlink(it, hv);
do_item_remove(it);
it = NULL;
}
Del Collections
Item Count Time
list 1,000,000 1000ms(1
second)set
Sorted set
hash
RDB
RDB is Redis
Snapshot
RDB
Fork(), Cow(Copy on Write)
Heavy Write 시에 메모리 이슈가 발생
할 수 있음.
Redis의 Replication은 무조건 Fork()
를 하므로 주의
RDB
17.1
GB
34.2
GB
68.4
GB
117
GB
메모리 사이즈에 따라서 생성 속도가
다름.
클 수록 느림…
Twice Memory
Twice Memory
Twice Memory
Write Error Case
읽기는 가능한데, 쓰기만 실패
Write Error Case
stop-writes-on-bgsave-error
RDB 생성 옵션이 켜져 있을 때, RDB
생성이 어떤 이유로 실패하면, 위의 옵
션으로 인해서 Write 작업이 금지됨.
Info는 되지만, Ping은 실패함
Write Error Case
“MISCONF Redis is configured to
save RDB snapshots, but is
currently not able to persist on
disk. Commands that may
modify the data set are disabled.
Please check Redis logs for
details about the error.”
Write Error Case
if (server.stop_writes_on_bgsave_err &&
server.saveparamslen > 0
&& server.lastbgsave_status ==
REDIS_ERR &&
c->cmd->flags & REDIS_CMD_WRITE)
{
flagTransaction(c);
addReply(c, shared.bgsaveerr);
return REDIS_OK;
}
Write Error Case
config set stop-writes-on-bgsave-error no
Redis.conf에서 옵션 off(2.6.12 이상)
AOF
AOF is Appended
only File
AOF
*3
$3
Set
$1
A
$3
abc
……
AOF Rewrite
- AOF 파일의 상태가 특정 조건(파일
사이즈가 얼마 이상일 경우)일 때
- AOF 파일을 현재 상태에 맞춰서 새
롭게 생성
- AOF Rewrite도 Fork() 사용하므로
RDB 와 같은 이슈가 발생
메모리 파편화
Redis 는 매번 메모리 할당을 하므로,
부하가 많을 경우, 튀는 경우가 발생.
실제로 Redis -> Arcus 는 전환시에 별
문제가 없었지만, Arcus -> Redis 는
전환시에 튀는 경우가 발생
Slab Allocator
Slab 0 Slab 1 Slab 2 … … Slab N
1mb 1mb 1mb 1mb 1mb 1mb 1mb 1mb
Slab Page List
Free Item List
LRU List
Slab 0 Slab 1 Slab 2 … … Slab NHead
Slab 0 Slab 1 Slab 2 … … Slab NTail
Item
Item
Item 밑에 있는 아이템일 수록 사용한지
오래됨.
Eviction
Memcached는 slab별 LRU 만 지원
Redis 는 LRU, Random 등을 지원
Twitter에서 사용하는 Twemcache 의
경우는 Eviction 전략만 추가한
Memcached의 변종?
LRU 관리
Memcached는 이전에는 LRU 관리에
이슈가 있었음.
LRU List를 뒤에서 부터 검색해서 메모
리를 확보함
다양한 Expire 값을 설정하면, Expire
가 짧은 아이템이 앞으로가, 뒤에서 찾
지못하고 메모리 할당의 가능성이 큼.
LRU 관리
Arcus는 뒤에서 부터 LRU List를 검색
하더라도, 처음까지 전부 체크함.
모두 한번에 체크하는 것은 아니라, 매
텀마다, 이전 기록을 바탕으로 검색
LRU 관리
최근 버전의 Memcache 는
LRU_Crawler라는 스레드가 추가됨.
Memcached는 독립 스레드에서,
Arcus 는 해당 LRU동작을 확장
LRU 관리
Redis 도 매 커맨드가 실행되기 전에 약
100여개 정도 랜덤하게 Eviction 정책
에 따라서 Key를 지움.
메모리 파편화
Memcached는 메모리 관리를 직접하
므로 문제가 덜함.
Redis 는 Jemalloc등을 사용하지만, 메
모리 할당을 직접 처리할 수 없으므로
메모리 파편화가 심해질 수 있다.
메모리 파편화
메모리 파편화
Memcache는 메모리를 자신이 관리하
므로, 실제 메모리 부족 시, 기존 데이
터를 지울 수 있다.
Redis는 Jemalloc에서는 메모리 Max
를 알지 못하므로, 그냥 새로운 Chunk
를 할당하게 된다.
Thank you.

Weitere ähnliche Inhalte

Was ist angesagt?

이것이 레디스다.
이것이 레디스다.이것이 레디스다.
이것이 레디스다.Kris Jeong
 
Node Js와 Redis를 사용한 구조화된 데이터
Node Js와 Redis를 사용한 구조화된 데이터Node Js와 Redis를 사용한 구조화된 데이터
Node Js와 Redis를 사용한 구조화된 데이터jinho park
 
Redis From 2.8 to 4.x(unstable)
Redis From 2.8 to 4.x(unstable)Redis From 2.8 to 4.x(unstable)
Redis From 2.8 to 4.x(unstable)DaeMyung Kang
 
Redis From 2.8 to 4.x
Redis From 2.8 to 4.xRedis From 2.8 to 4.x
Redis From 2.8 to 4.xDaeMyung Kang
 
카산드라를 설치해서 테스트 해보자 with virtualbox
카산드라를 설치해서 테스트 해보자 with virtualbox카산드라를 설치해서 테스트 해보자 with virtualbox
카산드라를 설치해서 테스트 해보자 with virtualbox떠리 이
 
[2B5]nBase-ARC Redis Cluster
[2B5]nBase-ARC Redis Cluster[2B5]nBase-ARC Redis Cluster
[2B5]nBase-ARC Redis ClusterNAVER D2
 
Cassandra 멘붕기 | Devon 2012
Cassandra 멘붕기 | Devon 2012Cassandra 멘붕기 | Devon 2012
Cassandra 멘붕기 | Devon 2012Daum DNA
 
Cassandra education material
Cassandra education materialCassandra education material
Cassandra education materialYoungki Kim
 
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석smartstudy_official
 
서버인프라 구축 입문 basis of composing server and infra
서버인프라 구축 입문 basis of composing server and infra서버인프라 구축 입문 basis of composing server and infra
서버인프라 구축 입문 basis of composing server and infraHwanseok Park
 
Node.js를 사용한 Big Data 사례연구
Node.js를 사용한 Big Data 사례연구Node.js를 사용한 Big Data 사례연구
Node.js를 사용한 Big Data 사례연구ByungJoon Lee
 
서버/인프라를 지탱하는 기술
서버/인프라를 지탱하는 기술서버/인프라를 지탱하는 기술
서버/인프라를 지탱하는 기술재훈 정
 
Mongodb 특징 분석
Mongodb 특징 분석Mongodb 특징 분석
Mongodb 특징 분석Daeyong Shin
 
실무로 배우는 시스템 성능 최적화 - 4부. 프로세스 이해하기
실무로 배우는 시스템 성능 최적화 - 4부. 프로세스 이해하기실무로 배우는 시스템 성능 최적화 - 4부. 프로세스 이해하기
실무로 배우는 시스템 성능 최적화 - 4부. 프로세스 이해하기Minchul Jung
 
분산저장시스템 개발에 대한 12가지 이야기
분산저장시스템 개발에 대한 12가지 이야기분산저장시스템 개발에 대한 12가지 이야기
분산저장시스템 개발에 대한 12가지 이야기NAVER D2
 
다중성 확보, 시스템 안정화
다중성 확보, 시스템 안정화다중성 확보, 시스템 안정화
다중성 확보, 시스템 안정화Choonghyun Yang
 

Was ist angesagt? (20)

이것이 레디스다.
이것이 레디스다.이것이 레디스다.
이것이 레디스다.
 
Redis
RedisRedis
Redis
 
Redis 2017
Redis 2017Redis 2017
Redis 2017
 
Redis edu 1
Redis edu 1Redis edu 1
Redis edu 1
 
Node Js와 Redis를 사용한 구조화된 데이터
Node Js와 Redis를 사용한 구조화된 데이터Node Js와 Redis를 사용한 구조화된 데이터
Node Js와 Redis를 사용한 구조화된 데이터
 
Redis From 2.8 to 4.x(unstable)
Redis From 2.8 to 4.x(unstable)Redis From 2.8 to 4.x(unstable)
Redis From 2.8 to 4.x(unstable)
 
Redis From 2.8 to 4.x
Redis From 2.8 to 4.xRedis From 2.8 to 4.x
Redis From 2.8 to 4.x
 
카산드라를 설치해서 테스트 해보자 with virtualbox
카산드라를 설치해서 테스트 해보자 with virtualbox카산드라를 설치해서 테스트 해보자 with virtualbox
카산드라를 설치해서 테스트 해보자 with virtualbox
 
[2B5]nBase-ARC Redis Cluster
[2B5]nBase-ARC Redis Cluster[2B5]nBase-ARC Redis Cluster
[2B5]nBase-ARC Redis Cluster
 
Cassandra 멘붕기 | Devon 2012
Cassandra 멘붕기 | Devon 2012Cassandra 멘붕기 | Devon 2012
Cassandra 멘붕기 | Devon 2012
 
Redis edu 4
Redis edu 4Redis edu 4
Redis edu 4
 
Cassandra education material
Cassandra education materialCassandra education material
Cassandra education material
 
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
 
서버인프라 구축 입문 basis of composing server and infra
서버인프라 구축 입문 basis of composing server and infra서버인프라 구축 입문 basis of composing server and infra
서버인프라 구축 입문 basis of composing server and infra
 
Node.js를 사용한 Big Data 사례연구
Node.js를 사용한 Big Data 사례연구Node.js를 사용한 Big Data 사례연구
Node.js를 사용한 Big Data 사례연구
 
서버/인프라를 지탱하는 기술
서버/인프라를 지탱하는 기술서버/인프라를 지탱하는 기술
서버/인프라를 지탱하는 기술
 
Mongodb 특징 분석
Mongodb 특징 분석Mongodb 특징 분석
Mongodb 특징 분석
 
실무로 배우는 시스템 성능 최적화 - 4부. 프로세스 이해하기
실무로 배우는 시스템 성능 최적화 - 4부. 프로세스 이해하기실무로 배우는 시스템 성능 최적화 - 4부. 프로세스 이해하기
실무로 배우는 시스템 성능 최적화 - 4부. 프로세스 이해하기
 
분산저장시스템 개발에 대한 12가지 이야기
분산저장시스템 개발에 대한 12가지 이야기분산저장시스템 개발에 대한 12가지 이야기
분산저장시스템 개발에 대한 12가지 이야기
 
다중성 확보, 시스템 안정화
다중성 확보, 시스템 안정화다중성 확보, 시스템 안정화
다중성 확보, 시스템 안정화
 

Ähnlich wie Redis edu 3

[OpenTRS-001] Hotel California
[OpenTRS-001] Hotel California[OpenTRS-001] Hotel California
[OpenTRS-001] Hotel CaliforniaTheori
 
[110730/아꿈사발표자료] mongo db 완벽 가이드 : 7장 '고급기능'
[110730/아꿈사발표자료] mongo db 완벽 가이드 : 7장 '고급기능'[110730/아꿈사발표자료] mongo db 완벽 가이드 : 7장 '고급기능'
[110730/아꿈사발표자료] mongo db 완벽 가이드 : 7장 '고급기능'sung ki choi
 
[14.10.20] 아! 그거...모르겠습니다 - TLS(devrookie)
[14.10.20] 아! 그거...모르겠습니다 - TLS(devrookie)[14.10.20] 아! 그거...모르겠습니다 - TLS(devrookie)
[14.10.20] 아! 그거...모르겠습니다 - TLS(devrookie)해강
 
[234]멀티테넌트 하둡 클러스터 운영 경험기
[234]멀티테넌트 하둡 클러스터 운영 경험기[234]멀티테넌트 하둡 클러스터 운영 경험기
[234]멀티테넌트 하둡 클러스터 운영 경험기NAVER D2
 
150120 Rack 어플리케이션 개요
150120 Rack 어플리케이션 개요150120 Rack 어플리케이션 개요
150120 Rack 어플리케이션 개요Shim Won
 
7가지 동시성 모델 4장
7가지 동시성 모델 4장7가지 동시성 모델 4장
7가지 동시성 모델 4장HyeonSeok Choi
 
간단한 쉘 스크립트 작성하기
간단한 쉘 스크립트 작성하기간단한 쉘 스크립트 작성하기
간단한 쉘 스크립트 작성하기licubeclub
 
Node.js DBMS short summary
Node.js DBMS short summaryNode.js DBMS short summary
Node.js DBMS short summaryHoChul Shin
 
log-monitoring-architecture.pdf
log-monitoring-architecture.pdflog-monitoring-architecture.pdf
log-monitoring-architecture.pdfSungkyun Kim
 
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?내훈 정
 
[211] HBase 기반 검색 데이터 저장소 (공개용)
[211] HBase 기반 검색 데이터 저장소 (공개용)[211] HBase 기반 검색 데이터 저장소 (공개용)
[211] HBase 기반 검색 데이터 저장소 (공개용)NAVER D2
 
OLAP for Big Data (Druid vs Apache Kylin vs Apache Lens)
OLAP for Big Data (Druid vs Apache Kylin vs Apache Lens)OLAP for Big Data (Druid vs Apache Kylin vs Apache Lens)
OLAP for Big Data (Druid vs Apache Kylin vs Apache Lens)SANG WON PARK
 
No sql 이해 및 활용 공개용
No sql 이해 및 활용 공개용No sql 이해 및 활용 공개용
No sql 이해 및 활용 공개용YOUNGGYU CHUN
 
Assembly 스터디 2
Assembly 스터디 2Assembly 스터디 2
Assembly 스터디 2Jinkyoung Kim
 
Intro KaKao ADT (Almighty Data Transmitter)
Intro KaKao ADT (Almighty Data Transmitter)Intro KaKao ADT (Almighty Data Transmitter)
Intro KaKao ADT (Almighty Data Transmitter)I Goo Lee
 

Ähnlich wie Redis edu 3 (20)

[OpenTRS-001] Hotel California
[OpenTRS-001] Hotel California[OpenTRS-001] Hotel California
[OpenTRS-001] Hotel California
 
[110730/아꿈사발표자료] mongo db 완벽 가이드 : 7장 '고급기능'
[110730/아꿈사발표자료] mongo db 완벽 가이드 : 7장 '고급기능'[110730/아꿈사발표자료] mongo db 완벽 가이드 : 7장 '고급기능'
[110730/아꿈사발표자료] mongo db 완벽 가이드 : 7장 '고급기능'
 
[14.10.20] 아! 그거...모르겠습니다 - TLS(devrookie)
[14.10.20] 아! 그거...모르겠습니다 - TLS(devrookie)[14.10.20] 아! 그거...모르겠습니다 - TLS(devrookie)
[14.10.20] 아! 그거...모르겠습니다 - TLS(devrookie)
 
(Lisp)
(Lisp)(Lisp)
(Lisp)
 
[234]멀티테넌트 하둡 클러스터 운영 경험기
[234]멀티테넌트 하둡 클러스터 운영 경험기[234]멀티테넌트 하둡 클러스터 운영 경험기
[234]멀티테넌트 하둡 클러스터 운영 경험기
 
150120 Rack 어플리케이션 개요
150120 Rack 어플리케이션 개요150120 Rack 어플리케이션 개요
150120 Rack 어플리케이션 개요
 
7가지 동시성 모델 4장
7가지 동시성 모델 4장7가지 동시성 모델 4장
7가지 동시성 모델 4장
 
간단한 쉘 스크립트 작성하기
간단한 쉘 스크립트 작성하기간단한 쉘 스크립트 작성하기
간단한 쉘 스크립트 작성하기
 
Node.js DBMS short summary
Node.js DBMS short summaryNode.js DBMS short summary
Node.js DBMS short summary
 
SPARK SQL
SPARK SQLSPARK SQL
SPARK SQL
 
Gcd ppt
Gcd pptGcd ppt
Gcd ppt
 
log-monitoring-architecture.pdf
log-monitoring-architecture.pdflog-monitoring-architecture.pdf
log-monitoring-architecture.pdf
 
HDFS Overview
HDFS OverviewHDFS Overview
HDFS Overview
 
Hadoop발표자료
Hadoop발표자료Hadoop발표자료
Hadoop발표자료
 
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
시즌 2: 멀티쓰레드 프로그래밍이 왜이리 힘드나요?
 
[211] HBase 기반 검색 데이터 저장소 (공개용)
[211] HBase 기반 검색 데이터 저장소 (공개용)[211] HBase 기반 검색 데이터 저장소 (공개용)
[211] HBase 기반 검색 데이터 저장소 (공개용)
 
OLAP for Big Data (Druid vs Apache Kylin vs Apache Lens)
OLAP for Big Data (Druid vs Apache Kylin vs Apache Lens)OLAP for Big Data (Druid vs Apache Kylin vs Apache Lens)
OLAP for Big Data (Druid vs Apache Kylin vs Apache Lens)
 
No sql 이해 및 활용 공개용
No sql 이해 및 활용 공개용No sql 이해 및 활용 공개용
No sql 이해 및 활용 공개용
 
Assembly 스터디 2
Assembly 스터디 2Assembly 스터디 2
Assembly 스터디 2
 
Intro KaKao ADT (Almighty Data Transmitter)
Intro KaKao ADT (Almighty Data Transmitter)Intro KaKao ADT (Almighty Data Transmitter)
Intro KaKao ADT (Almighty Data Transmitter)
 

Mehr von DaeMyung Kang

How to use redis well
How to use redis wellHow to use redis well
How to use redis wellDaeMyung Kang
 
The easiest consistent hashing
The easiest consistent hashingThe easiest consistent hashing
The easiest consistent hashingDaeMyung Kang
 
How to name a cache key
How to name a cache keyHow to name a cache key
How to name a cache keyDaeMyung Kang
 
Integration between Filebeat and logstash
Integration between Filebeat and logstash Integration between Filebeat and logstash
Integration between Filebeat and logstash DaeMyung Kang
 
How to build massive service for advance
How to build massive service for advanceHow to build massive service for advance
How to build massive service for advanceDaeMyung Kang
 
Massive service basic
Massive service basicMassive service basic
Massive service basicDaeMyung Kang
 
Data Engineering 101
Data Engineering 101Data Engineering 101
Data Engineering 101DaeMyung Kang
 
How To Become Better Engineer
How To Become Better EngineerHow To Become Better Engineer
How To Become Better EngineerDaeMyung Kang
 
Kafka timestamp offset_final
Kafka timestamp offset_finalKafka timestamp offset_final
Kafka timestamp offset_finalDaeMyung Kang
 
Kafka timestamp offset
Kafka timestamp offsetKafka timestamp offset
Kafka timestamp offsetDaeMyung Kang
 
Data pipeline and data lake
Data pipeline and data lakeData pipeline and data lake
Data pipeline and data lakeDaeMyung Kang
 
webservice scaling for newbie
webservice scaling for newbiewebservice scaling for newbie
webservice scaling for newbieDaeMyung Kang
 
Internet Scale Service Arichitecture
Internet Scale Service ArichitectureInternet Scale Service Arichitecture
Internet Scale Service ArichitectureDaeMyung Kang
 

Mehr von DaeMyung Kang (20)

Count min sketch
Count min sketchCount min sketch
Count min sketch
 
Ansible
AnsibleAnsible
Ansible
 
Why GUID is needed
Why GUID is neededWhy GUID is needed
Why GUID is needed
 
How to use redis well
How to use redis wellHow to use redis well
How to use redis well
 
The easiest consistent hashing
The easiest consistent hashingThe easiest consistent hashing
The easiest consistent hashing
 
How to name a cache key
How to name a cache keyHow to name a cache key
How to name a cache key
 
Integration between Filebeat and logstash
Integration between Filebeat and logstash Integration between Filebeat and logstash
Integration between Filebeat and logstash
 
How to build massive service for advance
How to build massive service for advanceHow to build massive service for advance
How to build massive service for advance
 
Massive service basic
Massive service basicMassive service basic
Massive service basic
 
Data Engineering 101
Data Engineering 101Data Engineering 101
Data Engineering 101
 
How To Become Better Engineer
How To Become Better EngineerHow To Become Better Engineer
How To Become Better Engineer
 
Kafka timestamp offset_final
Kafka timestamp offset_finalKafka timestamp offset_final
Kafka timestamp offset_final
 
Kafka timestamp offset
Kafka timestamp offsetKafka timestamp offset
Kafka timestamp offset
 
Data pipeline and data lake
Data pipeline and data lakeData pipeline and data lake
Data pipeline and data lake
 
Redis acl
Redis aclRedis acl
Redis acl
 
Coffee store
Coffee storeCoffee store
Coffee store
 
Scalable webservice
Scalable webserviceScalable webservice
Scalable webservice
 
Number system
Number systemNumber system
Number system
 
webservice scaling for newbie
webservice scaling for newbiewebservice scaling for newbie
webservice scaling for newbie
 
Internet Scale Service Arichitecture
Internet Scale Service ArichitectureInternet Scale Service Arichitecture
Internet Scale Service Arichitecture
 

Redis edu 3