---
title: "Building a Paste Service With ClickHouse"
description: "pastila.nl is a minimal paste service whose browser JavaScript sends INSERT and SELECT queries directly to an internet-facing ClickHouse instance."
url: "https://swe.quest/articles/building-a-paste-service-with-clickhouse-1cd0d0d493c69976"
canonical: "https://clickhouse.com/blog/building-a-paste-service-with-clickhouse"
source: "ClickHouse"
published: "2022-04-01"
difficulty: "medium"
kind: "Case study"
reading_minutes: 13
tags: ["databases","analytics","replication","system-design","javascript"]
---

# Building a Paste Service With ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2022-04-01, 13 min read, Case study. Original: [https://clickhouse.com/blog/building-a-paste-service-with-clickhouse](https://clickhouse.com/blog/building-a-paste-service-with-clickhouse)

## Summary

pastila.nl is a minimal paste service whose browser JavaScript sends INSERT and SELECT queries directly to an internet-facing ClickHouse instance. Content is addressed by a 128-bit SipHash plus a 32-bit locality-sensitive fingerprint built from the minimum hash of word shingles. Ordering the primary key by fingerprint keeps similar edits adjacent, so storing every keypress compresses to almost nothing. The schema relies on EPHEMERAL and MATERIALIZED columns and CHECK constraints for hash verification, size limits and entropy-based garbage rejection, and runs on a Replicated database with two-node ClickHouse Keeper across Frankfurt and Ohio behind Route53 geo DNS. The setup deliberately embraces anti-patterns, such as a two-node consensus cluster that loses write availability if either node fails.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- ClickHouse MergeTree tables ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- JavaScript Fetch API ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- hash functions

## Keywords

ClickHouse, ClickHouse Keeper, SipHash, ReplicatedMergeTree, pastila.nl, Route53, locality-sensitive hashing

## Related posts

- [Singapore Meetup Report: How ClickHouse Powers Ahrefs, the World's Most Active Web Crawler](https://swe.quest/articles/singapore-meetup-report-how-clickhouse-powers-ahrefs-the-world-s-most-active-53c5d742aa6dea19.md): ClickHouse · 2023-07-27 · Easy · 3 min read · Analytics & OLAP, Storage engines, Scaling, Replication
  Ahrefs moved its web-crawler and analytics storage from a custom system built on Quantcast File System plus Elasticsearch to ClickHouse in 2019.
- [How trip.com migrated from Elasticsearch and built a 50PB logging solution with ClickHouse](https://swe.quest/articles/how-trip-com-migrated-from-elasticsearch-and-built-a-50pb-logging-solution-with-079ade1f405efcf8.md): ClickHouse · 2024-06-12 · Medium · 16 min read · Analytics & OLAP, Observability, Scaling, Cost optimization, Databases
  Trip.com replaced its Elasticsearch-based centralized logging platform with ClickHouse after hitting stability, ingestion and cost limits at 4PB, and has since grown it toward 50PB.
- [Contentsquare Migration from Elasticsearch to ClickHouse](https://swe.quest/articles/contentsquare-migration-from-elasticsearch-to-clickhouse-052c118198db3e2f.md): ClickHouse · 2022-10-11 · Medium · 6 min read · Analytics & OLAP, Refactoring & migrations, Distributed databases, Performance engineering, Cost optimization
  Contentsquare replaced 14 Elasticsearch clusters with ClickHouse over a phased migration.
- [Didi Migrates from Elasticsearch to ClickHouse for a new Generation Log Storage System](https://swe.quest/articles/didi-migrates-from-elasticsearch-to-clickhouse-for-a-new-generation-log-storage-50fcb56512cab39a.md): ClickHouse · 2024-04-19 · Medium · 11 min read · Analytics & OLAP, Observability, Storage engines, Scaling, Cost optimization
  Didi replaced Elasticsearch with ClickHouse for petabyte-per-day log and trace storage, cutting machine cost by 30% and speeding up queries about 4x on a 400+ node single-replica deployment peaking at 40 GB/s writes and ~200 QPS.
- [ClickHouse 22.3 LTS Released](https://swe.quest/articles/clickhouse-22-3-lts-released-3d54b5a68fa989fa.md): ClickHouse · 2022-04-12 · Medium · 9 min read · Analytics & OLAP, Databases, Testing, Storage systems
  ClickHouse 22.3 is a long-term support release (supported through March 2023) focused on maturity and reliability.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
