Redis Kümesi ve Parçalama
Redis Cluster'ın karma yuvalarını kullanarak önbelleği birçok düğüme yatay olarak nasıl ölçeklediğini, anahtarların nasıl yönlendirildiğini ve karma etiketleriyle ilişkili anahtarları nasıl birlikte tutacağınızı öğrenin.
Redis Kümesi ve Parçalama, CoddyKit'te ücretsiz bir Caching Strategies: Redis + CDN + Edge Computing dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Caching Strategies: Redis + CDN + Edge Computing öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Caching Strategies: Redis + CDN + Edge Computing kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Why Scale Beyond One Node?
A single Redis instance is limited by one server's memory and throughput. Redis Cluster spreads data across many nodes so the cache can grow far beyond a single machine.
Hash Slots
Redis Cluster divides the keyspace into 16384 hash slots. Each node owns a range of slots. A key belongs to exactly one slot, determined by hashing the key.
TOTAL_SLOTS = 16384
def slot_for(crc):
return crc % TOTAL_SLOTS
print('Slot:', slot_for(123456789))CRC16 Routing
The slot is computed as CRC16(key) mod 16384. The client (or cluster) uses this to know which node holds the key, so reads and writes go directly to the right place.
Slot Distribution
With three nodes, slots split roughly into thirds. Adding a node means moving some slots to it; removing one redistributes its slots. This is how the cluster rebalances.
nodes = 3
per_node = 16384 // nodes
print('Approx slots per node:', per_node)MOVED and ASK Redirects
If a client contacts the wrong node, the node replies with a MOVED redirect pointing to the correct node. During slot migration, a temporary ASK redirect is used. Smart clients cache the slot map.
The Multi-Key Limitation
Operations across multiple keys (like MGET or transactions) only work if all keys live in the same slot. Otherwise the cluster rejects the command, because the keys may be on different nodes.
Hash Tags
Hash tags solve this. Only the part inside curly braces is hashed, so keys sharing a tag land in the same slot. user:{42}:profile and user:{42}:cart are co-located.
def hash_part(key):
if '{' in key and '}' in key:
start = key.index('{') + 1
end = key.index('}')
return key[start:end]
return key
print(hash_part('user:{42}:cart'))Replicas for Availability
Each master node can have replicas. If a master fails, a replica is promoted automatically, so the slot range stays available. This combines sharding with high availability.
Cluster vs Client-Side Sharding
Before Redis Cluster, apps sharded manually by hashing keys to instances in client code. Cluster mode moves that logic into Redis itself, handling rebalancing and failover automatically.
Trade-offs of Clustering
Clustering adds power but also constraints: cross-slot operations are limited, multi-key Lua scripts need same-slot keys, and operations are more complex. Use it when a single node truly is not enough.
When to Cluster
Reach for Redis Cluster when memory or throughput exceeds one node, when you need automatic failover at scale, or when a region demands many nodes. For smaller caches, a single primary with a replica is simpler.
Quick Check
You need MGET to fetch two related keys atomically in a Redis Cluster. How do you guarantee they live on the same node?
Recap
You learned Redis Cluster and sharding:
- The keyspace splits into 16384 hash slots owned by nodes.
- CRC16 routing plus MOVED/ASK redirects locate keys.
- Multi-key ops need same-slot keys; hash tags co-locate them.
- Replicas add automatic failover.
Clustering scales a cache horizontally when one node is not enough.
Yapay zeka eğitmeniyle Caching Strategies: Redis + CDN + Edge Computing öğren — ücretsiz
Tarayıcında gerçek kod yaz ve çalıştır, 7/24 yapay zeka eğitmeninden anında yardım al; web'de ya da uygulamada kaldığın yerden devam et.
- Kurslar
- 12
- Dersler
- 48
Sıkça Sorulan Sorular
“Redis Kümesi ve Parçalama” dersi ücretsiz mi?
Evet — “Redis Kümesi ve Parçalama” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Caching Strategies: Redis + CDN + Edge Computing kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Caching Strategies: Redis + CDN + Edge Computing kursu toplamda 4 dersten oluşur.
“Redis Kümesi ve Parçalama” dersinde ne öğreneceğim?
Redis Cluster'ın karma yuvalarını kullanarak önbelleği birçok düğüme yatay olarak nasıl ölçeklediğini, anahtarların nasıl yönlendirildiğini ve karma etiketleriyle ilişkili anahtarları nasıl birlikte… Caching Strategies: Redis + CDN + Edge Computing ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Caching Strategies: Redis + CDN + Edge Computing öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Caching Strategies: Redis + CDN + Edge Computing, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Redis Kümesi ve Parçalama” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Caching Strategies: Redis + CDN + Edge Computing dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Caching Strategies: Redis + CDN + Edge Computing dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Redis Kalıcılığı ve HA
- Redis ile Dağıtık Önbellekleme
- Geçersiz Kılma için Redis Pub/Sub
- Redis Kümesi ve Parçalama