Reddit Discussion · Apr 2025

Seeking Advice: Designing a High-Scale PostgreSQL System for Immutable Text-Based Identifiers

Backend System Design
6 upvotes 9 replies

Discussion

I’m designing a system to manage

Millions of unique, immutable text identifiers and would appreciate feedback on scalability and cost optimisation. Here’s the anonymised scenario: **Core Requireme

Full Details

I’m designing a system to manage

Millions of unique, immutable text identifiers and would appreciate feedback on scalability and cost optimisation. Here’s the anonymised scenario:

Core Requirements 1.

Data Model: * Each record is a unique, unmodifiable text string (e.g., xxx-xxx-xxx-xxx-xxx). (The size of the text might vary and the the text might only be numbers 000-000-000-000-000) * No truncation or manipulation allowed—original values must be stored verbatim. 2.

Scale: * Initial dataset: 500M+ records, growing by millions yearly. 3.

Workload: *

Lookups: High-volume exact-match queries to check if an identifier exists. *

Updates: Frequent single-field updates (e.g., marking an identifier as "claimed"). 4.

Constraints: * Queries do not include metadata (e.g., no joins or filters by category/source). * Data must be stored in PostgreSQL (no schema-less DBs).

Current Design *

Hashing: Use a 16-byte BLAKE3 hash of the full text as the primary key. *

Schema: ​ CREATE TABLE identifiers ( id_hash BYTEA PRIMARY KEY, -- 16-byte hash raw_value TEXT NOT NULL, -- Original text (e.g., "a1b2c3-xyz") is_claimed BOOLEAN DEFAULT FALSE, source_id UUID, -- Irrelevant for queries claimed_at TIMESTAMPTZ ); *

Partitioning: Hash-partitioned by id_hash into 256 logical shards.

Open Questions 1.

Indexing: * Is a B-tree on id_hash still optimal at 500M+ rows, or would a BRIN index on claimed_at help for analytics? * Should I add a composite index on (id_hash, is_claimed) for covering queries? 2.

Hashing: * Is a 16-byte hash (BLAKE3) sufficient to avoid collisions at this scale, or should I use SHA-256 (32B)? * Would a non-cryptographic hash (e.g., xxHash64) sacrifice safety for speed? 3.

Storage: * How much space can TOAST save for raw_value (average 20–30 chars)? * Does column order (e.g., placing id_hash first) impact storage? 4.

Partitioning: * Is hash partitioning on id_hash better than range partitioning for write-heavy workloads? 5.

Cost/Ops: * I want to host it on a VPS and manage it and connect my backend API and analytics via pgBouncher * Any tools to automate archiving old/unclaimed identifiers to cold storage? Will this apply in my case? * Can I effectively backup my database in S3 in the night?

Challenges *

Bulk Inserts: Need to ingest 50k–100k entries, maybe twice a year. *

Concurrency: Handling spikes in updates/claims during peak traffic.

Alternatives to Consider? · Is Postgresql the right tool here, given that I require some relationships? A hybrid option (e.g., Redis for lookups + Postgres for storage) is an option however, the record in-memory database is not applicable in my scenario. * Would a columnar store (e.g., Citus) or time-series DB simplify this?

What Would You Do Differently? * Am I overcomplicating this with hashing? Should I just use raw_value as the PK? * Any horror stories or lessons learned from similar systems? · I read the use of partitioning based on the number of partitions I need in the table (e.g., 30 partitions), but in case there is a need for more partitions, the existing hashed entries will not reflect that, and it might need fixing. (chartmogul). Do you recommend a different way? * Is there an algorithmic way for handling this large amount of data? Thanks in advance—your expertise is invaluable!

Free preview — 6 questions shown. Unlock all Scale questions →

About This Question

This is an interview discussion from a scale interview for a backend role during the system design round reported in 2025.

It covers the following topics: Ml, Trees, Strings, Sql, Os, System Design .

About Scale Interview Reports

This question was reported by a candidate who interviewed at Scale. LeakCode aggregates interview reports from 10+ sources, including 1Point3Acres, Glassdoor, LeetCode Discuss, Blind, Reddit, Indeed, and Nowcoder. Each report is translated where necessary, deduplicated against existing entries, and tagged by company, role, round type, and reporting date.

Use this question as one calibration data point, not a memorization target. Companies typically rotate their question pools every 2-4 months; the exact wording of a 2024 question may differ from what you encounter today. The underlying pattern, difficulty level, and follow-up depth at Scale are the higher-signal extractions to take from this report.

For broader preparation context, the Scale interview process typically includes a recruiter screen, one or two technical phone screens, and a 4-5 round on-site loop covering coding, system design (at L4+ levels), and behavioral. Reports tagged on LeakCode show the round-by-round distribution and typical difficulty calibration. To browse questions filtered by round type and seniority, use the company hub linked above.

How To Practice This Type of Question

Solve similar problems on LeetCode under timed conditions (25-35 minutes per medium difficulty). The goal is pattern recognition: recognize the underlying technique (sliding window, two-pointer, BFS, memoized recursion, etc.) within 60-90 seconds of reading. Strong candidates verbalize their hypothesis out loud before coding, then iterate based on feedback. Weak candidates dive into implementation immediately, lose time on the wrong approach, and run out of time for follow-ups.

Companies update their question pools every 2-4 months. The exact wording of any given question may have been retired by the time you interview. Focus your prep on the pattern, not the specific problem. The patterns that appear in Scale reports consistently are the ones worth investing in; one-off niche problems are not.

During Your Scale Round

Apply the standard interview round template: clarify requirements (2-3 minutes), state your approach out loud and confirm direction with the interviewer (3-5 minutes), code with narration (15-25 minutes), test with concrete examples including edge cases (5 minutes), discuss optimization or trade-offs if time permits (5 minutes). This template is universally accepted across FAANG and adjacent companies; deviating from it produces weaker interviewer feedback signal.

The single most predictive failure mode in Scale reports tagged "no hire": not asking clarifying questions. Interviewers are explicitly trained to weight this. Strong candidates ask 3-5 clarifying questions even on problems that look obvious; weak candidates dive into code immediately. The clarifying-question check is often the first signal recorded in the interviewer's written notes.