You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
shading으로 데이터는 수평분할 어 저장됨에 따라 scale out, 단일 장애 지점(SPOF) 개선, 성능 향상 등의 이점을 얻을 수 있으며, 클러스터 구조에 따라 복잡성이 증가할 수 있으므로 상황에 따라 적절한 구조를 선택하는 것이 필요합니다.
30
+

31
+
(출처:[How to work with Cluster Mode on Amazon ElastiCache for Redis](https://aws.amazon.com/ko/blogs/database/work-with-cluster-mode-on-amazon-elasticache-for-redis/))
32
+
aws article [How to work with Cluster Mode on Amazon ElastiCache for Redis](https://aws.amazon.com/ko/blogs/database/work-with-cluster-mode-on-amazon-elasticache-for-redis/)에서 다루고 있는 용어와 [redis.io 문서](https://redis.io/docs/latest/operate/oss_and_stack/management/sentinel/)에서 표현되는 용어가 미묘하게 다르지만, 위 이미지와 같이 비슷한 구조로 나누어 설명하고 있는것을 알 수 있습니다.
33
33
34
-
## Cluster Mode 종류
35
-
> AWS ElastiCache. But the truth is, ElastiCache isn’t Redis. Instead, it’s a Redis-compatible imitator managed by AWS with limited extra functionality.
34
+
## Redis Mode 별 차이 비교
35
+
aws article에서 각 mode별 구성에 대해 잘 정리한 표가 있어서 가져왔습니다. 앞서 언급한 내용과 같이 각각의 모드는 redis.io에서 언급하고 있는 standalone, sentienl, cluster mode와 유사한 범주로 언급하고 있음을 알 수 있습니다.
36
+

37
+
(출처:[How to work with Cluster Mode on Amazon ElastiCache for Redis](https://aws.amazon.com/ko/blogs/database/work-with-cluster-mode-on-amazon-elasticache-for-redis/))
36
38
37
-
(redis cloud 소개 관련 글에서 위와 같이 언급)[https://redis.io/cloud/compare-us-with-aws-elasticache/?utm_campaign=gg_s_competitor_bam_acq_apac-en&utm_source=google&utm_medium=cpc&utm_content=elasticache&utm_term=&gad_source=1&gclid=Cj0KCQjw1qO0BhDwARIsANfnkv9vMuzTeVvGvdHDSbmArIOkrxbHmuqfSoYLVemtJVpzkat8vF5lyNYaAtxzEALw_wcB]하며 차이를 소개하고 있지만 Cluster Mode의 경우 실제 운영 구조가 동일할 것이라고 생각되어 아래와 같이 가져왔습니다.
38
-
![[Pasted image 20240706163022.png]]
39
+
수평 확장을 통해 성능상의 이점 등을 얻기 위해선 결국 data partitioning을 통한 sharding이 되어야 하는데, redis의 경우 hashslot을 통해 파티셔닝을 처리하는 것을 아래 그림에서 설명하고 있습니다.
40
+

41
+
(출처:[How to work with Cluster Mode on Amazon ElastiCache for Redis](https://aws.amazon.com/ko/blogs/database/work-with-cluster-mode-on-amazon-elasticache-for-redis/))
42
+
43
+
따라서 aws managed 서비스인 elastiCache를 사용하든 별도로 구성된 cluster mode를 사용하든 현재 구성된 클러스터 구조를 확인하고 이해하고 있어야 sharding을 통해 얻을수 있는 이점과, 관리 포인트를 이해하고 주의할 수 있을 것 입니다.
39
44
40
45
# redis-cli로 cluster mode 환경 살펴보기
41
-
redis-cli를 설치하려면 환경에 맞게 (링크)[https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/] 에서 확인하고 설치해줍니다.
46
+
redis-cli를 설치하려면 환경에 맞게 [링크](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/) 에서 확인하고 설치해줍니다.
42
47
43
48
현재 실행된 환경을 확인하는 방법은 다음과 같습니다.
44
-
45
49
```sh
46
50
# Connect to Redis server
47
51
$ redis-cli -h 127.0.0.1 -p 6379
@@ -62,7 +66,26 @@ standalone 모드로 실행한 경우 아래와 같이 표시됩니다.
62
66
2) "no"
63
67
```
64
68
65
-
# Reference
69
+
aws elastiCache로 redis cluster를 구성한 경우 아래와 같은 방법으로 정보를 확인할 수 있습니다.
> CROSSSLOT Keys in request don't hash to the same slot
31
+
32
+
위와 같은 에러 메세지를 받았다면, cluster mode로 실행중인 redis에 [MGET](https://redis.io/docs/latest/commands/mget/)등으로 한번에 많은 요청을 받으려고 시도 할 때 발생합니다.
33
+
[aws 질문글](https://repost.aws/knowledge-center/elasticache-crossslot-keys-error-redis) 중에 관련된 내용이 있는데, 문제를 해결하기 위해서 키 내에 hashslot 명시하는 기준인 hashtag `{}` 를 포함하면 됩니다.
34
+
하지만, 기본적으로 cluster mode에서 hashslot이 저장되는 방식에 대한 이해를 바탕으로 hashslot을 설정하는 것이 좋습니다.
35
+
36
+
아래와 같은 key를 예시로 들어봅니다.
37
+
```
38
+
1. categories:movies:{1}:name
39
+
2. categories:{movies}:1:name
40
+
```
41
+
cluster mode의 경우 hashslot을 n개의 shard로 나누어 관리하므로 같은 공간에 저장되는 것이 좋습니다. 담고자 하는 정보가 동일한 hashslot에 묶여 함께 저장되길 바라는 곳에 `{}`를 포함해야 합니다.
42
+
43
+
따라서, 특정 영화의 여러 속성을 한 번에 가져오는 경우가 더 일반적이라면 첫 번째 구조를 추천합니다.
44
+
그러나 범주 내의 여러 영화를 한 번에 가져오는 경우가 더 일반적이라면 두 번째 구조를 사용할 수 있습니다.
0 commit comments