A vector clock is a logical timestamping mechanism used in distributed systems to capture causal relationships between events across different processes or nodes. Each node maintains a vector—an array of counters—where each element corresponds to a known node in the system. When an event occurs locally, the node increments its own counter; when sending a message, it includes its current vector, allowing recipients to merge and update their local view of causality. This enables the system to determine if one event happened-before another, if they are concurrent, or if they are causally related, which is essential for conflict detection in eventually consistent databases and version control systems.
