0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · Ders

İstemci Tarafında Bağlantı Dayanıklılığı

Yeniden denemeler, timeouts, bağlantı havuzları ve küme farkındalıklı yeniden yönlendirme işlemleriyle istemcilerin yük devretmelerinden ve topoloji değişikliklerinden etkilenmeden çalışmasını sağlayın.

İstemci Tarafında Bağlantı Dayanıklılığı, CoddyKit'te ücretsiz bir Redis Caching & Messaging (Pub/Sub, Streams) 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, Redis Caching & Messaging (Pub/Sub, Streams) öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Redis Caching & Messaging (Pub/Sub, Streams) kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

HA Is a Two-Sided Deal

You configured replication, Sentinel, and Cluster on the server. But high availability only works if the client reacts correctly to failovers, moved slots, and dropped connections. This lesson covers client-side resilience.

Connection Pools

Opening a TCP connection per command is slow. A connection pool reuses a set of connections across requests, bounded by a maximum size to protect the server.

pool = redis.ConnectionPool(max_connections=50)
client = redis.Redis(connection_pool=pool)

Timeouts Matter

Without timeouts, a stalled node can hang your whole app. Set both a connect timeout and a socket/command timeout so failed nodes fail fast.

client = redis.Redis(socket_connect_timeout=2, socket_timeout=2)

Retries with Backoff

Transient errors (a brief failover) should be retried, ideally with exponential backoff to avoid hammering a recovering node.

for attempt in range(3):
    try:
        return client.get('key')
    except ConnectionError:
        time.sleep(2 ** attempt)

Sentinel-Aware Clients

With Sentinel, the client asks Sentinel for the current master address rather than hardcoding it. After a failover, the client re-queries and reconnects to the new master.

from redis.sentinel import Sentinel
s = Sentinel([('s1', 26379)], socket_timeout=0.5)
master = s.master_for('mymaster')

Reading from Replicas

For read-heavy workloads, route reads to replicas to offload the master. Be aware replicas may be slightly behind (eventual consistency).

replica = s.slave_for('mymaster')
value = replica.get('key')

Handling MOVED in Cluster

In a cluster, a key may live on a different node. The server replies MOVED with the correct node. A cluster-aware client follows the redirect and updates its slot map.

# (error) MOVED 3999 127.0.0.1:7002

Handling ASK Redirects

During slot migration the server may reply ASK, a one-time redirect. The client should send ASKING then the command to the target node, without permanently updating its slot map.

# (error) ASK 3999 127.0.0.1:7003
# client sends ASKING then retries on 7003

Refreshing the Topology

Cluster-aware clients periodically refresh their slot-to-node map and on receiving redirects, so they keep routing to the right node as the cluster reshards.

CLUSTER SLOTS
CLUSTER SHARDS

Idempotency and Retries

Retrying writes is risky if the first attempt actually succeeded. Prefer idempotent operations (SET, INCR with a dedup key) so a retry cannot double-apply an effect.

Putting It Together

Resilient clients combine pools, timeouts, backoff retries, Sentinel/cluster awareness, replica reads where safe, and idempotent writes. Together they turn server-side HA into end-to-end availability.

Quick Check

Test your understanding of client resilience.

Recap

You learned client-side resilience: connection pools, connect and command timeouts, exponential backoff retries, Sentinel-aware master discovery, replica reads, and handling MOVED/ASK redirections in a cluster. Combine these with idempotent writes for true end-to-end availability.

Sıkça Sorulan Sorular

“İstemci Tarafında Bağlantı Dayanıklılığı” dersi ücretsiz mi?

Evet — “İstemci Tarafında Bağlantı Dayanıklılığı” 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 Redis Caching & Messaging (Pub/Sub, Streams) kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Redis Caching & Messaging (Pub/Sub, Streams) kursu toplamda 4 dersten oluşur.

“İstemci Tarafında Bağlantı Dayanıklılığı” dersinde ne öğreneceğim?

Yeniden denemeler, timeouts, bağlantı havuzları ve küme farkındalıklı yeniden yönlendirme işlemleriyle istemcilerin yük devretmelerinden ve topoloji değişikliklerinden etkilenmeden çalışmasını sağlay… Redis Caching & Messaging (Pub/Sub, Streams) 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.

Redis Caching & Messaging (Pub/Sub, Streams) öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Redis Caching & Messaging (Pub/Sub, Streams), 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.

“İstemci Tarafında Bağlantı Dayanıklılığı” 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 Redis Caching & Messaging (Pub/Sub, Streams) dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Redis Caching & Messaging (Pub/Sub, Streams) 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

  1. Yedeklilik için Redis Çoğaltması
  2. Yüksek Erişilebilirlik için Redis Sentinel
  3. Parçalama için Redis Cluster
  4. İstemci Tarafında Bağlantı Dayanıklılığı
← Redis Caching & Messaging (Pub/Sub, Streams) Sayfasına Dön