Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Clickhouse has a pretty good endpoint /replicas_status which gives information about the, guess what, replication status. When you are working on a cluster in which you use replication to increase the amount of QPS you usually have a load balancer before, something like this:

                                 +--------------+
                                 |              |
                       +-------->+  clickhouse  |
                       |         |              |
                       |         +--------------+
                       |
                       |
+--------------+       |         +--------------+
|              |       |         |              |
|   load       +---------------->+  clickhouse  |
|   balancer   |       |         |              |
|              |       |         +--------------+
+--------------+       |
                       |
                       |         +---------------+
                       |         |               |
                       +-------->+  clickhouse   |
                                 |               |
                                 +---------------+

Sometimes you insert a new fresh replica and when that happens the health checks on the new replica start to work so the load balancer will throw traffic to machine that does not have data yet.

So using /replicas_status as the health check will leave out the new replica until it catchup with the rest of the replicas.

If you call it with ?verbose=1 return detailed information for each replicated table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment