메뉴
HN
Hacker News 36일 전

Memcached 찬양: Redis보다 매력적인 이유

IMP
7/10
핵심 요약

캐시 도입 시 가장 먼저 떠오르는 Redis는 시간이 지나면서 개발자들에 의해 영구적인 DB처럼 오용되어 운영자에게 큰 부담을 줍니다. 반면 Memcached는 디스크 저장 기능이 없고 클라이언트 기반 클러스터링을 지원하여 장애 처리가 매우 단순합니다. 단순한 캐시가 필요한 인프라 환경이라면 운영 및 관리 측면에서 Memcached가 훨씬 안정적이고 가벼운 선택지가 될 수 있습니다.

번역된 본문

시스템 관리자 직무를 맡고 있거나 누군가의 인프라를 유지 보수해야 하는 입장이라면, 언젠가 "캐시가 필요하다"는 주제가 반드시 등장할 것입니다. 당신은 잠시 생각하다가 익숙하고, 기능이 풍부하며, 잘 작동하기 때문에 Redis를 떠올릴 것입니다. 훌륭하고 견고한 캐시라는 기억을 떠올리며, 최신 버전에서 어떤 새로운 기능들이 추가되었는지 궁금해하고 홈페이지로 향합니다. "귀하의 에이전트가 실패하는 것이 아닙니다. 컨텍스트가 실패하는 것입니다. 문의하는 에이전트들은 알고 싶어 합니다: AI 앱을 위한 실시간 컨텍스트 엔진으로 Redis Iris를 어떻게 사용할 수 있나요? 1" 네, 아마도 AI와 관련된 무언가인 모양입니다. 2. 돈을 벌고 싶어 하는 회사이기 때문에 Redis의 이런 모습은 어느 정도 이해할 수 있습니다.

어쨌든 Redis 홈페이지는 그렇다 치고, 이를 배포하고 믿음직스러운 캐시로 사용하기 시작합니다. 캐시를 요청했던 사람들에게 연결 문자열을 전달하고 일을 진행하죠. 몇 달 후, 시간이 지나면서 cache.set("key", "value")가 정말 단순한 추상화라는 것이 밝혀집니다. INSERT INTO table VALUES ('key', 'value')를 사용하는 것보다 확실히 쉽기 때문이죠. 사람들은 REmote DIctionary Server(REmote DIctionary Server)를 항상 존재하고, 데이터를 영속시키며, 데이터베이스 그 자체인 것처럼 취급하기 시작합니다.

당신은 이 사실을 모릅니다. 운영팀 동료들도 모릅니다. 따라서 당신의 알림 시스템도 이를 알지 못하는데, 사람들이 캐시를 휘발성으로 취급할 것이라고 가정했기 때문입니다. 당신이 우연히 Redis에 무언가 작업을 할 때 이러한 상황이 진행되고 있었다는 것을 깨닫게 됩니다. 업그레이드를 하거나, 다른 노드로 이동하거나, 당신의 고양이가 RAID0 서버의 HDD 트레이 배출 버튼을 누른 것일 수도 있습니다. 문제는 Redis에 영속성 기능이 없다는 것이 아닙니다. 진짜 문제는 보통 Redis가 스택에 '캐시'로 도입되며, 사람들도 그것을 그렇게 취급할 것이라고 예상하고 운영된다는 점입니다. 보통 이 사실을 깨달을 때쯤이면 이미 너무 늦었고, Redis가 애플리케이션에 너무 깊게 얽혀 있어 자리를 비키기 어렵습니다. 대신 애완동물처럼 유지하고 모니터링하는 영원한 즐거움(고통)을 누리게 됩니다.

Memcached의 등장 그래서 memcached란 대체 무엇일까요? 쉽습니다. 웹사이트에 물어보세요: Memcached란 무엇인가? 무료 및 오픈 소스, 고성능, 분산 메모리 개체 캐싱 시스템으로, 범용적이지만 데이터베이스 부하를 완화하여 동적 웹 애플리케이션의 속도를 높이는 데 사용됩니다. 3 와우, 페이지 첫 문장에 코드 예제까지 있군요. 그리고 상단의 귀여운 마스코트들도 보세요! Memcached는 Redis와 비슷한 캐시입니다. Django처럼 플러그 형식의 캐싱을 지원하여 서로 다른 캐싱 백엔드로 전환할 수 있는 프레임워크를 사용하고 있을 확률이 높습니다. 하지만 Redis보다 기능이 훨씬 적은데 왜 memcached를 사용해야 할까요? 제가 요즘 Redis보다 항상 memcached를 선호하는 이유는 다음과 같습니다:

  • memcached의 다운타임을 다루는 것은 믿을 수 없을 정도로 쉽습니다. 왜냐하면 클라이언트 라이브러리가 일반적으로 연결 예외를 무시하기 때문입니다. 예를 들어, 서버가 다운된 경우 단순한 get 호출은 기본값(또는 아무것도 반환하지 않음)을 반환합니다.
  • memcached를 클러스터링하는 것은 멋집니다. 왜냐하면 memcached에는 내장된 클러스터링이 실제로 없기 때문입니다. 이를 "클러스터링"하려면 클라이언트 라이브러리를 여러 URL 4 로 구성하기만 하면 되며, 클라이언트는 키 해싱을 기반으로 대상 인스턴스를 선택합니다. 클라이언트 측 호출에서 인스턴스가 죽은 것으로 감지되면 해셔에서 해당 노드를 제거합니다. 특정 시간이 지나면 클라이언트는 자동으로 다시 연결을 시도하고 죽은 노드를 사용합니다.
  • memcached는 디스크에 영속하지 않기 때문에 전체 영속성 문제를 "해결"합니다. 따라서 원하는 곳 어디든 상태 비저장(stateless) 워크로드로 예약하기에 완벽한 적합합니다.

이러한 것들이 Redis에서 불가능한 것은 아닙니다. 다만 memcached의 아키텍처가 일반적으로 이러한 방향에 더 기울어져 있어서 운영 관점에서 훨씬 더 간단 명료하게 만듭니다. 하지만 memcached가 상대적으로 매우 단순한 애플리케이션이라는 사실(게다가)

원문 보기
원문 보기 (영어)
If you happen to find yourself in a sysadmin position, or a position where you just so happen to maintain someone’s infrastructure , chances are that at some point in time the topic “we need a cache” comes up. You think for a moment and reach out for Redis, because you’re used to it, it’s fully featured, and it works! You remember it being a good, solid cache, and you wonder which new features recent releases have brought, and head to its homepage: Your agents aren’t failing. Their context is. Inquiring agents want to know: How can I use Redis Iris as a real-time context engine for AI apps? 1 Right, so probably something with AI 2 . This is sort of understandable, because Redis is a company that wants to make money. Anyways, Redis homepage aside, you deploy it, and off you go - your trusty cache. You hand the connection string to the people who asked for it, and off you go. Few months later After a while, it turns out that cache.set("key", "value") is a really simple abstraction, and definitely easier than INSERT INTO table VALUES ('key', 'value') . People start treating the REmote DIctionary Server as something that’s always there, something that persists data, something that is a database . You don’t know this. Your ops colleagues don’t know this. Therefore, your alerting doesn’t know this either, because you assume that people treat the cache as something volatile. You find out that this has been going on when you happen to do something to Redis. Maybe you upgrade it, maybe you move it to another node, maybe your cat hits the eject button on your RAID0 server’s HDD tray. The issue isn’t that Redis doesn’t have persistence, the issue is that usually, Redis is brought into a stack as a cache , and it is run with the assumption that people treat it that way. Usually, by the time you realize this, it is already too late, and Redis is too intertwined in the app to really leave its place. Instead, you have the eternal pleasure of maintaining it and monitoring it like a pet. Enter memcached First off - what’s a memcached? Easy, ask its website : What is Memcached? Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. 3 Wow, first sentence on the page, even with code examples. And look at those cute little mascots at the top! Memcached is also a cache, similar to Redis. Chances are that you’re using a framework like Django, which supports pluggable caching and allows you to switch between different caching backends. But why should you use memcached when it has much less features than Redis? Here are my reasons for why these days, I will always prefer memcached over Redis: Dealing with memcached downtime is incredibly easy, because client libraries generally ignore connection exceptions. For instance, a simple get will just return the default value (or none) if the server is down. Clustering memcached is wonderful, because memcached actually has no clustering built-in. To “cluster” it, you configure the client library with multiple URLs 4 , and the client will select the target instance based on hashing the key. If a client-side call detects an instance as done, it removes the node from the hasher . After a certain time, the client will automatically attempt to reconnect and use the dead node. memcached “solves” the whole persistence issue, because it does not persist to disk. It is therefore a perfect fit to just being scheduled as a stateless workload wherever you desire it. None of these things are impossible with Redis, it’s just that memcached’s architecture in general more leans towards these directions, which makes it much, much more straightforward from an operations point of view. But because of memcached being such a relatively simple application (plus the fact that you can run dozens instances of it with ~64 MB cache size and close to no overhead), if I need a cache these days, I usually reach out to memcached. That said, a lot of “database too slow” problems actually begin their life as “query too slow” or “missing indices”, so be a kind person and help your developers with optimizing their queries. Also, if you’re curious about some of the decisions behind memcached, the blog contains interesting posts, with one published just in May: “How Long Does That Response Take… For Real?” . https://redis.io/ , accessed 2026-06-02  ↩︎ That said, https://redis.io is probably not the best entrypoint for engineers, that website seems geared to people making purchasing decisions.  ↩︎ https://memcached.org , accessed 2026-06-02  ↩︎ Bonus points for using a service discovery mechanism to automatically generate this setting.  ↩︎