DATABASE/REDIS
REDIS는 왜 싱글스레드 일까?
Rainbound-IT
2022. 6. 29. 14:58
반응형
우선 REDIS는 인메모리캐시를 위해 만들어 져서 메모리에 사용할땐 싱글스레드가 유용하다고 한다.
Redis가 단일 스레드인 4가지 이유
- CPU는 병목이 아님 : Redis의 모든 작업은 메모리 기반이며 CPU는 Redis의 병목이 아닙니다. 대부분의 경우 Redis의 병목 현상은 컴퓨터 메모리 또는 네트워크 대역폭의 크기일 가능성이 큽니다. 단일 스레드 Redis로 더 높은 성능을 원한다면 클러스터(다중 프로세스) 솔루션을 사용할 수 있습니다.
- 동시성 : 병렬 처리가 여러 클라이언트를 지원하는 유일한 전략은 아닙니다. Redis는 epoll및 이벤트 루프를 사용하여 동시성 전략을 구현하고 컨텍스트 전환 없이 많은 시간을 절약합니다.
- 구현하기 쉬움 : 다중 스레드 프로그램을 작성하는 것은 더 어려울 수 있습니다. 스레드에 대한 잠금 및 동기화 메커니즘을 추가해야 합니다.
- 간편한 배포 : 단일 스레드 응용 프로그램은 최소 단일 CPU 코어가 있는 모든 시스템에 배포할 수 있습니다.
Reference
https://dev.to/snj/why-redis-is-single-threaded-37p0
인 메모리 캐시라서
https://blog.katastros.com/a?ID=00750-d514be4d-94f6-4dd8-8d31-d45d8002478e
반응형