Skip to Content
Analytics

How Zenifra ClickHouse works

This page shows how Zenifra managed ClickHouse is configured: how many instances each plan uses, how data is replicated, how the connection is protected, and what the application user can do. To create and connect, see Getting started with ClickHouse and Connections and clients.

Summary

ItemHow it is
Version26.8 (26.8.36.3)
EngineOfficial ClickHouse, no fork
TablesReplicatedMergeTree by default in the app database
Instances1 or 3, depending on the plan, always 1 shard
CoordinationClickHouse Keeper with 3 instances
Memory and CPUreserved per instance, at the plan values
Public portstwo, both with TLS: Native TLS and HTTPS
Userapp, with the app database, no administrative access
System logssystem.query_log for 7 days; the others for 3 days
Backupsautomatic, every 8 to 24 hours, depending on the plan
Plansanalytics-sandbox, analytics-starter, analytics-production, and analytics-enterprise

Version

Every new ClickHouse uses version 26.8 (26.8.36.3), from the official ClickHouse image.

To check your database version:

SELECT version();

Instances, CPU, and memory per plan

The values below apply to each instance. The plan CPU and memory are reserved for the instance and are not shared with other projects.

PlanInstancesvCPU per instanceMemory per instance
analytics-sandbox112 GiB
analytics-starter1416 GiB
analytics-production328 GiB
analytics-enterprise3416 GiB
  • The number of instances follows the plan. To go from 1 to 3 instances, or from 3 to 1, change the plan. See Changing plans.
  • Every ClickHouse has 1 shard. In 3-instance plans, each instance is a full replica of the data.
  • Each instance has its own disk, at the size you chose. Included storage and billing are in Analytics plans.
  • Console metrics are available from analytics-starter up.

Memory and queries

  • The plan memory is the ceiling of each instance. Queries, merges, and caches share that space.
  • Queries with large GROUP BY or JOIN use more memory. Filter by time range and by the sorting key to read less data.
  • Server parameters are managed by Zenifra and follow the plan. What can be tuned per query, with SETTINGS or SET, is up to you.

To check the memory limits of your instance and your session:

SELECT name, value FROM system.server_settings WHERE name LIKE 'max_server_memory_usage%';
SELECT getSetting('max_memory_usage');

Tables, parts, and inserts

  • The app database is created with the Replicated engine: a CREATE TABLE, ALTER, or DROP run on one instance is applied to the others.
  • Without ENGINE in CREATE TABLE, the app user creates the table with ReplicatedMergeTree. To pick the engine, use a Replicated* variant, such as ReplicatedReplacingMergeTree.
  • Each INSERT writes a new part of the table. In the background, ClickHouse combines smaller parts into larger ones (merge).
  • Send inserts in batches, with thousands of rows at a time, not one row per INSERT. Many small inserts create many parts and slow the table down.
  • Tables with non-replicated engines, such as MergeTree, Memory, or Log, keep their data only on the instance that received the insert.

Replication and high availability

  • In 3-instance plans, every replica accepts reads and writes. An insert received by one replica is copied to the others.
  • Coordination between replicas uses ClickHouse Keeper, with 3 instances on different servers. Each project has its own space in Keeper.
  • The 3 instances of a ClickHouse always run on different servers, close to each other on the network, so that a server failure does not take down all replicas together.
  • Each instance disk is replicated in storage. If a server goes down, the instance comes back on another server with the same data.
  • When changing to a 1-instance plan, Zenifra first checks that the replicas are in sync and that there is no data in non-replicated tables. If there is, the change is refused with a message that says what to do.

Failover

  • The public address only leads to instances that respond. Each instance is checked every 5 seconds.
  • In 3-instance plans, if a replica fails, new connections go to the others, with no action from you. The host and ports in the console do not change.
  • Open connections to the failed instance drop. Configure your application to reconnect and retry idempotent inserts and queries.
  • In 1-instance plans, the instance restarts automatically, on the same server or on another one, with the same data.

Encryption and TLS

  • Public ports: each project gets two ports, both with TLS: Native TLS, for clickhouse-client and native drivers, and HTTPS, for JDBC, DBeaver, and HTTP clients. The port numbers are shown in the console. See Connections and clients.
  • Private connections between applications: also use TLS, on ports 9440 (Native TLS) and 8443 (HTTPS). See Private connections between applications.
  • Public certificate: the host is clickhouse-<id>.managed.zenifra.com, with a certificate validated by the system authorities, no certificate file needed. Always connect through the console host, not the IP.
  • At rest: ClickHouse data disks are encrypted.

User and permissions

  • The application user is app, with the app database. The password is stored as a SHA-256 hash and can be changed in the console. See Operations and troubleshooting.
  • In the app database, the app user has: SELECT, INSERT, CREATE TABLE, CREATE VIEW, ALTER, DROP TABLE, DROP VIEW, and TRUNCATE.
  • Server administration (parameters, users, replication, backups, and versions) is handled by Zenifra.

System logs

ClickHouse keeps query and event history in tables of the system database. Zenifra sets how long each one is kept:

TableRetention
system.query_log7 days
system.part_log, system.text_log, system.metric_log, system.asynchronous_metric_log, system.query_metric_log, system.query_views_log, system.error_log3 days
  • system.text_log keeps messages from the warning level up.

To see the slowest queries in the last hour:

SELECT query_duration_ms, read_rows, memory_usage, query
FROM system.query_log
WHERE type = 'QueryFinish' AND event_time > now() - INTERVAL 1 HOUR
ORDER BY query_duration_ms DESC
LIMIT 10;

Backups

Backups are automatic and included in the plan:

PlanFrequencyRetention
analytics-sandboxevery 24 hours3 days
analytics-starterevery 24 hours7 days
analytics-productionevery 12 hours14 days
analytics-enterpriseevery 8 hours30 days

See Automatic backups.

Next steps

Last updated on

On this page