Traditional vs Distributed SQL

Software Engineer | Open Source Enthusiast | Mentor | Learner I love documenting stuff that I come across and find interesting. Hoping that you will love reading it and get to know something new :)
Search for a command to run...

Software Engineer | Open Source Enthusiast | Mentor | Learner I love documenting stuff that I come across and find interesting. Hoping that you will love reading it and get to know something new :)
No comments yet. Be the first to comment.
Authentication is at the core of every secure digital system. As organizations scale and move to the cloud, the way we manage user identities must evolve. Concepts like Single Sign-On (SSO), OAuth2, LDAP, and modern platforms like Auth0 are crucial t...
AI development often presents an illusion of standardization. When engineering structured workflows, JSON Schema is universally relied upon to force Large Language Models into returning predictable, t

Large language models (LLMs) like Llama, Qwen, and DeepSeek are transforming how software interacts with data. However, moving these models from a local experimental script to a highly available, mult

Artificial Intelligence (AI) models, especially large language models (LLMs) like GPT, Claude, or Gemini, have transformed how we interact with computers. Yet, terms like tokens, token limits, quotas, tokenizers, and parameters can seem confusing at ...

JavaScript development involves many concepts and tools that help developers organize, share, and reuse code effectively. For newcomers, terms such as library, framework, UMD, and CDN can seem technical, and understanding their roles is essential for...

Large language models (LLMs) such as GPT, LLaMA, and Falcon have billions of parameters. While these models are powerful, their size makes them challenging to run and adapt for specific use cases. Three key concepts help solve this problem: quantizat...

In the world of databases, scaling and high availability are critical requirements for modern applications. Traditionally, SQL databases have been the backbone of data persistence due to their strong consistency, support for ACID transactions, and familiarity. However, as applications grow and go global, the limitations of traditional SQL systems become apparent—particularly around horizontal scalability, fault tolerance, and distributed writes. This has led to the emergence of distributed SQL databases, which promise the same SQL capabilities, but with the scalability and availability of distributed systems.
Traditional SQL databases such as MySQL, PostgreSQL, and SQL Server are generally designed as single-node systems. They are vertically scalable, meaning you can increase performance by adding more CPU, RAM, or storage to a single machine. While this approach is simple and effective up to a point, it eventually hits physical and cost limitations.
To improve read performance and availability, many cloud providers support read replicas. In this model, one primary database node handles all writes, and multiple read-only replicas handle read traffic. This setup is called active-passive, where only the primary is active for writes, and the rest are passive (used only for reads). If the primary node fails, a replica can be promoted, but this usually involves failover logic and some downtime.
The active-passive model is simple and consistent but comes with limitations. Writes are a bottleneck since they must go to a single node. While it improves read scalability, it doesn’t help with write-heavy workloads. Cross-region writes are also not feasible unless using manual replication or introducing complex conflict resolution.
Advantages:
Strong consistency
Simpler to implement
Works well for read-heavy workloads
Disadvantages:
Single point of failure for writes
Limited scalability
High write latency in global applications
When a single-node SQL database cannot handle the load, a common solution is sharding. Sharding is the practice of splitting a database into smaller partitions based on a shard key (like user ID). Each shard is a separate database and is typically hosted on its own server or node.
While sharding helps scale out the database, it introduces application-level complexity. The application must know how to route queries to the correct shard, manage connections, and potentially merge data from multiple shards for cross-shard queries. This makes development and operations more complex and error-prone.
Distributed SQL databases aim to solve these challenges by combining the familiarity of SQL with the architecture and scalability of distributed systems. These databases automatically shard and replicate data across multiple nodes while preserving ACID guarantees. To the developer, it looks like a single logical database, even though it's running on a distributed cluster.
Examples of distributed SQL databases include Google Spanner, CockroachDB, YugabyteDB, and Azure Cosmos DB for PostgreSQL (based on Citus). These systems are built to run across data centers, regions, or even clouds, offering automatic failover, scaling, and strong consistency.
At a high level, distributed SQL systems use three core mechanisms:
Automatic sharding: The database automatically splits data into shards based on a partitioning key. These shards are distributed across different nodes in the cluster.
Replication: Each shard is replicated to multiple nodes for high availability. One replica is designated as the leader (for writes), and others serve as followers or backups.
Consensus protocols: Distributed systems use algorithms like Raft or Paxos to ensure that all replicas agree on the state of a shard. This ensures consistency and enables failover without data loss.
A query in a distributed SQL system is routed to the appropriate shards, processed in parallel, and then aggregated and returned to the client. All of this is handled by the database engine, abstracting the complexity from developers.
Unlike traditional SQL systems, many distributed SQL databases support active-active configurations. In this model, multiple nodes (often in different regions) can accept writes and reads simultaneously. The system uses consensus and coordination to ensure consistency, even when writes come from different locations.
Advantages:
No single point of failure
Low-latency writes from any region
Built-in fault tolerance and scalability
Disadvantages:
More complex coordination
Slightly higher write latency due to consensus
More complex conflict resolution in some cases
One challenge in distributed databases is ensuring that transactions that span multiple shards or nodes maintain atomicity and consistency. This is typically achieved using the Two-Phase Commit (2PC) protocol or Distributed Transaction Coordinators (DTC).
Here's how Two-Phase Commit works:
Prepare phase: The transaction manager sends a prepare request to all involved shards. Each shard locks its resources and reports back whether it can commit.
Commit phase: If all shards agree, the transaction manager sends a commit message. Otherwise, it sends a rollback.
While 2PC ensures consistency, it can be slow and introduces the risk of locks if a participant crashes during the process. Modern distributed databases often use optimized variants or consensus-based protocols like Raft to manage transaction states more efficiently.
Traditional SQL databases are reliable and consistent but struggle with horizontal scaling and distributed architectures. To achieve high availability and scalability in modern applications, organizations are increasingly adopting distributed SQL systems. These databases retain the power of SQL while offering built-in sharding, replication, and fault tolerance across multiple nodes and regions.
Distributed SQL does not replicate entire datasets to every node. Instead, it smartly divides data into shards and replicates each shard, balancing performance, scalability, and consistency. By using consensus protocols and distributed transaction coordinators, these systems ensure that even in complex multi-node environments, data integrity is never compromised.
For teams building modern, scalable applications—especially in the cloud—distributed SQL offers a compelling blend of familiarity, performance, and resilience.
Reach out in the comments below or on LinkedIn to let me know what you think of it.
For more updates, do follow me here :)