redis on aws

65
Redis on AWS 내 Redis가 왜 AWS 느리다고 느껴질까? [email protected]

Upload: dae-myung-kang

Post on 21-Aug-2015

1.451 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Redis on AWS

Redis on AWS 내 Redis가 왜 AWS 느리다고 느껴질까?

[email protected]

Page 2: Redis on AWS

발표자 소개

• 강대명

• 카카오스토리 개발

• 잉엽니다.

• Redis Contributor

Page 3: Redis on AWS

솔직하게… Frankly Speaking…

Page 4: Redis on AWS

카카오는 AWS 거의 안써요.

Page 5: Redis on AWS

그런데… 왜…

Page 6: Redis on AWS

개인적으로는 AWS를 공부용으로만 씁니다.

Page 7: Redis on AWS

Spot을 사랑합니다.

Page 8: Redis on AWS

발표 내용은 예전에 뽀록…

Page 9: Redis on AWS

꿍님이 5분만 해도 된다고 해서…

Page 10: Redis on AWS

날로 먹겠습니다.

Page 11: Redis on AWS

오늘의 주제…

Page 12: Redis on AWS

왜 Redis가 AWS에서는 느리다고 느껴질까?

Page 13: Redis on AWS

Redis Latency Spikes

Page 14: Redis on AWS

이상하게 응답이 느릴 때가 존재…

Page 15: Redis on AWS

그런데 AWS 에서는 더 자주 느린 거 같네…

Page 16: Redis on AWS

먼저 결론…

Page 17: Redis on AWS

결론

• AWS라고 특별히 느릴 껀 없음.

– PV 대신에 HVM 쓰면됨

– 디스크 좋은 거 써야함…

– VPC 쓰는게 조금 더 좋을수도(이건 모든 클라우드가…)

• 나머지는 안 지키면 아무거나 다 느림

Page 18: Redis on AWS

이제 끝…

Page 19: Redis on AWS

하기에는 증거를 밝히고…

Page 20: Redis on AWS

PV vs HVM

Page 21: Redis on AWS

AWS 는 Xen 을 사용

Page 22: Redis on AWS

두 개의 차이는 잘 모릅니다.

Page 23: Redis on AWS

PV vs HVM

• PV

– Paravirtualization 반가상화

• HVM

– Hardware assisted Virtual Machine

Page 24: Redis on AWS

PV vs HVM

Page 25: Redis on AWS

PV vs HVM

• Xen 에서 PV 일 경우 fork 시에 page tables을 복사하는데 부하가 걸림…

– 왜 걸리는지는 묻지 말아주세요. PV에서 그냥 느립니다.

• Page tables의 사이즈에 영향을 받음.

• 실제 머신의 물리 메모리의 크기 보다는 레디스가 사용하는 Page 에 영향을 받음

Page 26: Redis on AWS

PV vs HVM (m3.xlarge) - ms

메모리 PV HVM

0 0.5 0.1

608MB 143 5

1.54G 352 13

2.31G 517 20

4.62G 1208 안재봄

6.16G 1600 안재봄

Page 27: Redis on AWS

fork 20x~30x 차이가 남

Page 28: Redis on AWS

OpenStack(KVM) 물리 서버

HVM과 유사

Page 29: Redis on AWS

이게 왜 문제임?

Page 30: Redis on AWS

Base Knowledge

Page 31: Redis on AWS

Redis는 싱글 스레드

Page 32: Redis on AWS

키가 몇 백만개 있는 서버에서

Page 33: Redis on AWS

Key * 한번 실행해보세요.

Page 34: Redis on AWS

망합니다.

Page 35: Redis on AWS

Flushall 한번 해보세요.

Page 36: Redis on AWS

역시 망하죠…

Page 37: Redis on AWS

Redis 는 싱글 스레드…

Page 38: Redis on AWS

한번에 하나의 작업만 처리합니다.

Page 39: Redis on AWS

그런데 fork 에서 시간이 1초가 더 걸리면?

Page 40: Redis on AWS

메모리 사용량이 적을 때는 큰 문제 없음.

Page 41: Redis on AWS

디스크?

Page 42: Redis on AWS

EBS는 네트웍 스토리지…

Page 43: Redis on AWS

그냥 로컬에 쓰면

Page 44: Redis on AWS

인스턴스 재시작 하면 사라짐

Page 45: Redis on AWS

그런데 디스크에 자주 쓰면…

Page 46: Redis on AWS

망합니다.

Page 47: Redis on AWS

대부분 레디스를 디폴트로 씀…

Page 48: Redis on AWS

SAVE 900 1 SAVE 300 10

SAVE 60 10000

Page 49: Redis on AWS

RDB는 마스터에서 안쓰는게

Page 50: Redis on AWS

꼭 써야하면 슬레이브에서

Page 51: Redis on AWS

이렇게 하고 메모리 많이 쓰면.

Page 52: Redis on AWS

물리 서버 써도 망합니다.

Page 53: Redis on AWS

Redis는 2.8.13 뒤에껄…

Page 54: Redis on AWS

Elastic Cache의 Redis는?

Page 55: Redis on AWS

2.8.19로 선택하세요.

Page 56: Redis on AWS

왜???

Page 57: Redis on AWS

Jemalloc 3.6.0

Page 58: Redis on AWS

메모리 사용량과 파편화가 줌

Page 59: Redis on AWS

아니면 Redis Labs 써도…

Page 60: Redis on AWS

이게 많이 고쳐서 메모리 덜 먹음…

Page 61: Redis on AWS

이 변화가 지금 Redis Unstable에 들어가고 있음

Page 62: Redis on AWS

SADD RedisLab Antirez

Page 63: Redis on AWS

다시 결론…

Page 64: Redis on AWS

결론

• AWS라고 특별히 느릴 껀 없음.

– PV 대신에 HVM 쓰면됨

– 디스크 좋은 거 써야함…

– VPC 쓰는게 조금 더 좋을수도(이건 모든 클라우드가…)

• 수행 시간이 긴 명령 쓰지 마셈.

• 2.8.13 이후로… 신상이 좋음

Page 65: Redis on AWS

감사합니다.