rb is a Python library for interacting with multiple Redis nodes, providing automatic routing of commands based on keys and broadcasting capabilities. It uses a cluster abstraction to manage connections to individual Redis instances, with routers (partition or consistent hashing) to determine the correct node for key-based operations. The library features a promise-based model for parallel execution, allowing non-blocking I/O via multiplexing (poll/epoll/kqueue) to handle multiple Redis connections efficiently. Key features include automatic batching of compatible commands (e.g., merging multiple GETs into MGET), fault tolerance through reconnection logic, and support for both routed and fanout operations. The codebase is well-structured with clear separation of concerns between cluster management, routing, client interfaces, and utility components.
CIM (Cross-platform Instant Messaging) is a production-grade, modular instant messaging framework built with Java 17, Spring Boot 3.3, and Netty. It provides a complete IM solution including a Netty-based server (cim-server) for handling client connections and message forwarding, a routing server (cim-forward-route) for message routing, user login/offline management, and a client SDK (cim-client-sdk) for building custom clients. The system uses Zookeeper for service discovery, Redis for caching and session management, and optionally MySQL for offline message persistence. It supports group chat, private chat, offline messages, delayed messages, emoji, AI mode, and a built-in command system. The architecture is microservice-oriented with clear separation of concerns, and the codebase demonstrates strong engineering practices including consistent hashing for server selection, a custom ring buffer wheel for delayed tasks, a dynamic HTTP proxy for RPC calls, and a trie-based prefix search. The project includes comprehensive unit and integration tests, Docker support, and CI/CD pipelines.
Sekiro is a multi-language, distributed RPC framework designed to expose capabilities from restricted or hard-to-reach environments. The server is a Java application built on Netty that listens on a configurable port (default 5612) and supports three transport protocols: a custom binary protocol (Sekiro native), HTTP, and WebSocket. It acts as a central hub: external consumers send invocation requests (via HTTP or the native protocol), and the server routes them to registered client handlers running in restricted environments (e.g., mobile apps, internal networks). The server maintains client groups with consistent hashing and queue-based load balancing, and handles heartbeats, timeouts, and connection lifecycle. It also includes a built-in proxy for serving documentation and static content. Architecturally, the server uses a protocol detection pipeline (ProtocolDetector) to identify the incoming protocol and install the appropriate handlers. For HTTP, it aggregates requests and delegates to ServiceHttp, which parses parameters and forwards invocations to the appropriate client group. For the native Sekiro protocol, it decodes packets and routes to RouterSekiro, which handles client registration and invoker connections. WebSocket clients are also supported for environments where raw TCP is unavailable. The system is stateless at the server level, with all client state managed in-memory via NettySekiroGroup instances. Key entry points are the Bootstrap.main() method, which starts the Netty server, and the various handler classes (ServiceHttp, RouterSekiro, ServiceSekiroClient, ServiceSekiroInvoker, ServiceWsClient). External dependencies include a custom Netty fork (sekiro-business-api), commons-lang3, SLF4J/Logback, and Lombok. The project uses Maven for building and includes a build script that produces a distributable zip. The codebase demonstrates solid engineering practices: clean separation of concerns, use of Netty's event loop model, a custom single-threaded event loop (Looper) for thread-safe group management, consistent hashing for client allocation, and a sampling-based event recording system for debugging. While the project is not a general-purpose RPC framework, it solves a specific niche (exposing capabilities from restricted contexts) effectively and with reasonable code quality.
This repository provides reference implementations of common system design patterns in Python and Java. It is primarily an educational resource containing standalone algorithm implementations for consistent hashing, rate limiting (token bucket, leaky bucket, sliding window variants), and load balancing algorithms (round robin, weighted round robin, least connections, least response time, IP hash). The code serves as a learning tool for system design interviews and concepts rather than a production-ready application. Each implementation is self-contained with usage examples embedded in the source files. The repository has no external dependencies beyond standard libraries, making it easy to extract and study individual patterns.