Why MySQL is not CA


motivation

I was recently discussing with my CTO about databases. There was one point where we were thinking about the CAP theorem. Then he randomly mentioned that MySQL is not CA. I was surprised because I always thought that MySQL is a CA database at its core.

Now I had to search and understand why MySQL is not CA.


CAP theorem

CAP theorem

We have always been taught in Engineering that CAP is one of the most important theorems in distributed systems and databases. We just accepted it. Time to question and learn ┏ʕ •ᴥ•ʔ┛

Here is what it actually means.

Imagine a bank server, when you check your account balance it should not randomly change it based on the server you are hitting and it should be consistent across all nodes. But in a distributed system, network failures (partitions) can occur. The CAP theorem states that you can only guarantee 2 out of 3 properties:

Here are practical examples of each combination:

CA Systems (Consistent + Available, but not Partition Tolerant)

Example: Traditional Relational Databases (like PostgresSQL in single-node setups)

Imagine a single PostgresSQL database server in a bank. When you check your balance:

This works perfectly in non-distributed environments, but fails when you need to scale across multiple data centers.

CP Systems (Consistent + Partition Tolerant, but sacrifices Availability)

Example: Apache ZooKeeper or etcd

Imagine a distributed configuration management system like ZooKeeper:

In a ZooKeeper cluster, if a majority of nodes become unreachable, the system stops accepting writes to prevent inconsistent states.

AP Systems (Available + Partition Tolerant, but sacrifices Consistency)

Example: Amazon DynamoDB or Cassandra

Imagine a social media platform’s like counter system:

You might see a post with 100 likes on one page refresh, then 102 likes on the next refresh, as the systems reconcile the differences asynchronously.


Why MySQL is not CA

While MySQL can achieve CA in single-node deployments, it cannot be truly CA in distributed scenarios. When you add MySQL replicas or clustering solutions like MySQL Group Replication:

It doesn’t enforce strong ACID guarantees across replicas the way PostgreSQL doe

Why PostgreSQL is considered CA

Postgres in standalone mode: Definitely CA (strong ACID, always responds if node is up).

In replication setups:

PostgreSQL replication (especially with synchronous replication) prioritizes consistency first. A commit can be acknowledged only after replicas confirm the write (if you configure synchronous replication).

This means if replicas aren’t reachable, Postgres will prefer not to serve stale data (sacrificing availability to preserve consistency).

So Postgres is effectively CA (or CP in distributed setups).

This is why distributed databases like CockroachDB or TiDB are often preferred for truly distributed, partition-tolerant systems.


ʕ ● ᴥ ●ʔ

Reply to this post by email ↪