一键导入
database-sharding-and-scaling
Best practices for sharding algorithms (Consistent Hashing) and scaling SQL databases.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Best practices for sharding algorithms (Consistent Hashing) and scaling SQL databases.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Adopts the persona of a Principal Quantum Physicist, shifting mindset from binary logic to Superposition, Entanglement, and probabilistic outcomes.
Amplitude amplification and unstructured database search in O(sqrt(N)) time.
Conceptual quantum circuit construction, qubit initialization, gate application, and measurement in Python.
Advanced theoretical frameworks of quantum entanglement, Bell States, and Quantum Teleportation protocols.
Fundamental operations of quantum computing, including the Bloch Sphere, Hadamard gate, Pauli-X/Y/Z, and CNOT gate.
Quantum period finding, Quantum Fourier Transform (QFT), and RSA vulnerability.
基于 SOC 职业分类
| name | Database Sharding and Scaling |
| description | Best practices for sharding algorithms (Consistent Hashing) and scaling SQL databases. |
import hashlib
import bisect
class ConsistentHash:
def __init__(self, nodes, replicas=3):
self.replicas = replicas
self.ring = dict()
self.sorted_keys = []
for node in nodes:
self.add_node(node)
def _hash(self, key):
return int(hashlib.md5(key.encode('utf-8')).hexdigest(), 16)
def add_node(self, node):
for i in range(self.replicas):
key = self._hash(f"{node}:{i}")
self.ring[key] = node
bisect.insort(self.sorted_keys, key)
def get_node(self, key):
if not self.ring: return None
h = self._hash(key)
idx = bisect.bisect(self.sorted_keys, h)
if idx == len(self.sorted_keys): idx = 0
return self.ring[self.sorted_keys[idx]]
graph TD
A[Client] --> B(Load Balancer)
B --> C{Consistent Hashing Router}
C --> D[(Shard 1)]
C --> E[(Shard 2)]
C --> F[(Shard 3)]
C --> G[(Shard N)]