Fading Coder

One Final Commit for the Last Sprint

Implementing a Red Packet Rain System with Redis and Lua

In 2018, live quiz shows like Wang Sicong's "Chongding Dahui," Xigua Video's "Million Heroes," and Inke's "Cheese Superman" became wildly popular. An e-commerce company I worked for joined this trend, and the tech team developed a live quiz feature. After a quiz ended,...

Implementing Redis Caching in Django

Establishing a Redis Connection Pool To efficiently manage connections to a Redis server, it's best practice to use a connection pool. This avoids the overhead of establishing a new connection for every request. import redis # Define the Redis connection pool configuration redis_pool = redis.Connect...

Implementing Automatic Master-Slave Failover for Redis High Availability on Two Servers

Redis Deployment Options When deploying Redis, several common approaches are available: This article presents a mutual master-slave approach using only two servers, similar to MySQL's replication, without requiring keepalived by using crontab and iptables for automation. System Requirements Server C...

Integrating Redis with Spring Boot Applications

Redis Cleints in Java In Java applications, interacting with Redis requires a Redis client library, similar to using JDBC for MySQL operations. Several reliable Java clients are available: Jedis Lettuce Spring Data Redis Spring provides comprehensive integration through Spring Data Redis, and Spring...

Redis High Availability with Master-Replica Replication and Sentinel Monitoring

Prepare all nodes in the cluster by installing build dependencies and extracting the Redis source distribution: yum install -y gcc make tcl curl -fsSL https://download.redis.io/releases/redis-7.0.12.tar.gz -o /usr/src/redis.tar.gz tar -xzf /usr/src/redis.tar.gz -C /usr/src/ cd /usr/src/redis-7.0.12...

Redis Data Durability: RDB Snapshots and AOF Logs

Redis achieves exceptional speed by keeping the entire dataset in memory. To prevent data loss during restarts, crashes, or power failures, it provides two persistence strategies: RDB (Redis Database) snapshots and AOF (Append Only File) logs. RDB Persistence RDB acts as the default persistence mech...

Redis Sentinel Mode: Automatic Failover for High Availability

Overview Manual master-slave failover requires human entervention—stop the application, reconfigure a slave, update configuration files, and restart. This process is time-consuming and introduces service downtime. Redis Sentinel, introduced in version 2.8, provides an automated solution for this pro...

Understanding Redis Cluster: Architecture, Data Partitioning, and High Availability

Distributed Database Fundamentals Distributed databases address three critical requirements: Scalability: When data volume or read/write load exceeds a single machine's capacity, load must be distributed across multiple nodes. This horizontal scaling approach handles increased demand by adding more...

Understanding Redis Single-Threaded Architecture and Core Commands

Fundamantal Redis Commands Redis provides essential commands for key-value operations. The most basic are: SET key value: Assigns a value to a key. GET key: Retrieves the value of a key. Returns nil if the key doesn’t exist. To handle binary-safe strings correctly in the CLI, use redis-cli --raw. Gl...

Deploying a High-Availability Redis Cluster on CentOS 7

System Environment and Prerequisites This guide outlines the procedure for establishing a Redis Cluster with six nodes (three masters and three slaves) on a sinngle CentOS 7 server. In a production setting, these instances should be distributed across multiple physical servers to ensure true fault t...