Skip to content

Conversation

@singsangssong
Copy link
Collaborator

🔗 Related Issue

⌨️ What I did

원하는 key string을 하나의 노드에 저장할 수 있도록 그룹화하는 Shard Key 기능을 구현합니다.
shard 결정을 위해서는 key의 일부만을 사용하며, 해당 조건은 아래와 같습니다.

  • 키에 {...} 패턴이 포함될 경우, 전체 키 대신 {} 사이의 문자열만을 해싱하여 저장할 노드를 결정합니다.

    • 처음 등장하는 {와 처음 등장하는 } 사이의 하나 이상의 문자열을 해싱
  • 이를 통해 동일한 Shard Key를 가진 키들은 항상 같은 노드에 배치됨을 보장하도록 합니다.

  • 테스트코드는 새로운 ArcusShardKeyTest클래스를 추가했습니다.

    • 키 전체가 서로 다르더라도 하나의 노드에 모두 저장되는지 확인
    • shard key값이 다르다면 서로 다른 노드로 분산되는지 확인
    • 키에 Shard key 규칙에 관한 패턴이 없다면 전체 키를 통해 해싱하는지 확인

uhm0311

This comment was marked as resolved.

uhm0311
uhm0311 previously approved these changes Nov 27, 2025
@oliviarla

This comment was marked as resolved.

@singsangssong

This comment was marked as resolved.

@uhm0311

This comment was marked as resolved.

oliviarla

This comment was marked as resolved.

oliviarla
oliviarla previously approved these changes Dec 5, 2025
oliviarla
oliviarla previously approved these changes Dec 5, 2025
uhm0311
uhm0311 previously approved these changes Dec 5, 2025
@jhpark816 jhpark816 added the merged next time PR will be merged next time. label Dec 5, 2025
@singsangssong singsangssong dismissed stale reviews from uhm0311 and oliviarla via e4c2caf December 9, 2025 09:24
@singsangssong
Copy link
Collaborator Author

https://github.com/jam2in/arcus-works/issues/790#issuecomment-3629954750

위에서 코멘트 주신대로 useShardKey필드를 추가하고, shard key 사용 여부를 설정할 수 있도록 했습니다.
생성자 인자를 수정하면서, 관련된 부분도 수정했습니다. 참고부탁드립니다.

uhm0311
uhm0311 previously approved these changes Dec 10, 2025
);

for (String key : keys) {
assertEquals("100", replLocator.getShardKey(key));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

직접 Locator 생성해서 테스트하는 케이스(unit test)는 ArcusKetamaNodeLocatorTest 로 옮기는 게 나아보입니다.

그러면 이 클래스에서는 client쪽에서 shard key가 담긴 키에 대한 요청을 서버에 보낼 때(integration test) 어떻게 처리하는지만 검증하면 됩니다.

}

@Override
public boolean getUseShardKey() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set/get 형태 말고 enableShardKey / isShardKeyEnabled 메서드명은 어떤가요?

@oliviarla
Copy link
Collaborator

MemcachedClient#validateKey 에서 {, } 가 prefix에 포함되어도 유효한 키로 간주해야 합니다.

@oliviarla
Copy link
Collaborator

리뷰 가능한 상태가 되면 요청 주세요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged next time PR will be merged next time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants