Every night a 6 TB Cassandra table events_by_user (replication factor 3) must land in the lake as Parquet on S3. The cluster has two datacenters: prod, which serves the app with a p99 read latency under 20 ms, and analytics, which holds a full replica and serves nobody else. The first attempt ran SELECT * FROM events_by_user ALLOW FILTERING from one Python process with paging: it ran for 14 hours, timed out twice, and the app's p99 doubled while it ran. The app writes at LOCAL_QUORUM in prod. The export must finish within 4 hours, must not affect app latency, and the lake team wants to know how consistent the copy is. Design the export: how the work is split, where and at which consistency level it reads, how load is limited, what consistency the copy has, and when you would copy SSTable snapshots instead.
Split the scan by token ranges, read in parallel by the Spark Cassandra Connector, pinned to the analytics DC and throttled per core, at LOCAL_QUORUM (default LOCAL_ONE). No cluster-wide snapshot exists: the copy is fuzzy over the run, so load it idempotently by key.
- Paging through
ALLOW FILTERINGfrom one client instead of splitting the token ring into parallel range scans - Running the export against the serving datacenter, or against every node, and competing with the application for the same replicas
- Calling the result a snapshot, when each token range is read at a different moment during the run
- How would you turn the nightly full export into an incremental one when the table has no reliable change timestamp?
- Why can one oversized Cassandra partition still leave a single straggling Spark task?
Splitting the work. The token ring is cut into pieces; the Spark Cassandra Connector estimates size from system.size_estimates and creates a Spark partition per roughly spark.cassandra.input.split.sizeInMB (512 MB by default) — about 12,000 tasks for 6 TB. Each task is a query token(user_id) > ? AND token(user_id) <= ?, a sequential read within the range, with no ALLOW FILTERING. A Cassandra partition is never split between tasks, so one huge user partition becomes a straggler.
Where and how to read.
spark.cassandra.connection.localDC=analytics:prodnodes are not touched at all.spark.cassandra.input.throughputMBPerSec(orreadsPerSec) sets a per-core limit, and times the number of cores, the overall ceiling; there is no limit by default.spark.cassandra.input.consistency.level:LOCAL_ONEby default. The app writes atLOCAL_QUORUMinprod, and writes reachanalyticsasynchronously, soLOCAL_QUORUMthere costs more but smooths over a lagging replica;LOCAL_ONEis cheaper and may return a stale row.
Consistency of the copy. Ranges are read at different moments over four hours: a row updated at 01:00 lands in the copy old or new, depending on when its range was read. It is a fuzzy copy: it is written to Parquet with the run date and loaded into the lake idempotently by key (overwrite the run-date partition, or MERGE). If a point in time is required, the export is combined with CDC or a cutoff on the write timestamp.
SSTable snapshots. nodetool snapshot creates hard links to the files instantly and puts no read load on the node, but one node holds only its share of ranges, and replicas give duplicates and different versions of a row: you must collect snapshots from every node of one datacenter and merge them by key on the latest timestamp (tombstones included). Teams do this when even a throttled scan is unacceptable or the copy is one-off — at the price of their own SSTable-parsing pipeline.