Managed ClickHouse
Run ClickHouse, the column-oriented database for real-time analytics, without a server to look after. We take care of provisioning and patch updates, and storage is included in the flat plan price.
Create a ClickHouse database
- Go to Databases and click Create database.
- Select ClickHouse.
- Enter a Name. It must be unique in your organization.
- Select the Data center your servers run in. See Regions.
- Select a Plan.
- Turn on Allow public access if clients outside your private networks connect to the database.
- Click Create database.
ClickHouse runs on a single node, so there's no replica to pick. The database is ready when its status reads Running.
Plans
ClickHouse compresses data heavily, so the storage holds far more raw data than its size suggests. Concurrent queries are the capacity limit, because each analytical query uses every core. A query over the limit fails right away with Too many simultaneous queries, so queue queries in your client, for example with a bounded worker pool. Connections are cheap, and you can open up to 1,000 at once.
By default, each query can use up to half the RAM, and big aggregations and sorts spill to disk instead of failing. Traffic over private networks is free. Outbound traffic from table functions such as url() and s3(), and from the Kafka engine, counts as internet egress. See Pricing philosophy for its price.
Connect to your database
Open the database and find the hostname, the defaultdb database, the admin user and its password under Connection. Copy database URL gives you a ready-made connection string for your app. To connect from a terminal, set the hostname as CH_HOST and the password as CH_PASSWORD:
A new database is reachable only from the private networks attached to it. There, it serves the native protocol on port 9000, or 9440 with TLS, and HTTP on port 8123, or 8443 with HTTPS.
Allow public access opens only the TLS ports, 9440 and 8443, on a separate public hostname. Certificates are issued by the Better Stack Managed CA, which isn't in system trust stores, so pass the CA certificate to your client. betterstack clickhouse credentials <name> --availability-zone us-west-2a returns the public hostname in public_uri and the CA certificate in ca_certificate. Save the certificate as betterstack-db-ca.pem and set the public hostname as CH_PUBLIC_HOST. Restrict who can connect with a firewall.
Connection hangs from outside Cloud?
The hostname resolves to a private address, so it works only from your private networks. From the internet, turn on public access and connect to the public hostname.
Rotate credentials
To replace the admin password:
- Click Rotate credentials on the database page.
- Click Rotate credentials to confirm.
The previous password keeps working for 24 hours, so roll your clients within that window. Users you create yourself aren't affected.
Users and databases
admin manages your data with plain SQL. CREATE DATABASE, CREATE USER, CREATE ROLE, row policies and quotas work as they would on your own server:
Session settings, such as max_memory_usage and max_threads, can be changed with SET. SYSTEM FLUSH LOGS, SYSTEM DROP CACHE, SYSTEM RELOAD DICTIONARY and KILL QUERY work. Server file access and commands that control the server, such as SYSTEM SHUTDOWN, aren't available.
The built-in default user is locked. Anything that connects back to the database, such as a dictionary with a ClickHouse source, must name USER 'admin' and its password, or another user you created.
Single node and recovery
ClickHouse runs without replicas, so there's no failover. If the node's machine fails, we recover it with its data. If the data itself is lost, your latest snapshot is what you get back, so take snapshots often.
Everything that runs on a single node works, such as the MergeTree family, materialized views, projections, TTLs, dictionaries, the Kafka engine and async inserts. Replicated table engines, the Replicated database engine, ON CLUSTER DDL, KeeperMap and S3Queue aren't available.
Snapshots
Click Take a snapshot on the database page. The database keeps serving while the snapshot is taken, and every acknowledged synchronous insert is in it. Data in Buffer tables, and async inserts acknowledged before they were written, can be missing. Snapshots outlive the database. To restore one, see Database snapshots.
Restored database lists detached parts?
A snapshot taken under write load restores with parts that a merge was still writing. ClickHouse lists them in system.detached_parts with reason broken-on-start, and your data is all in the active parts. Once you've checked it, remove each part with ALTER TABLE <table> DROP DETACHED PART '<name>' to free the disk space.
Rescale and disk usage
To change the plan:
- Click Rescale on the database page.
- Select a Plan and click Rescale database.
The node stops, resizes and starts again, so the database is unavailable for a few minutes. You can move to a smaller plan only if your data fits within 80% of its storage.
When storage fills up, you get warnings first:
The disk never fills up completely. ClickHouse keeps a free-space floor and refuses a write that doesn't fit with NOT_ENOUGH_SPACE, while smaller writes and all reads keep working.
To free space, drop or truncate old partitions, add a TTL … DELETE clause to large tables, or rescale to a bigger plan. TRUNCATE frees space right away.
After a merge, the old parts stay on disk for about 8 minutes, so a heavy bulk load can briefly use more space than your data. Insert in large batches and leave headroom, or rescale up for the load and back down afterwards.
Updates
We apply ClickHouse patch releases automatically. Each one restarts the node, which takes from a few seconds to a minute.
Need help?
Please let us know at hello@betterstack.com.
We're happy to help! 🙏