All projects

Databases · distributed systems

Cassandra in practice: a 3-node cluster, a failure test and ten years of data

With two classmates, I explored how Cassandra copes with large amounts of data: we designed the schema around our queries, ran a 3-node cluster that kept answering with one node down, and compared it with PostgreSQL over ten years of simulated sensor data.

Period
October – November 2026
Status
Completed · group project (3 students)
Type
Academic project
  • Apache Cassandra 5.0
  • CQL
  • PostgreSQL 15
  • Docker
  • Python
  • nodetool
  • LaTeX

The project

Coursework for the Information Systems course at ENSGMM (2026–2027), done by three of us and supervised by the lecturer. The topic: how wide-column databases handle large amounts of distributed data. We worked on a concrete case, a sensor network writing a reading every few seconds for years, where the database has to stay fast as history grows and survive losing a machine. We first showed how the model works on a real cluster, then measured where it wins and where it loses against a well-indexed relational database.

  • Schema designed from six queries, giving four tables. Duplication is expected in this model.
  • Partition key (sensor_id, day): day bucketing caps each partition at about 8,640 rows per sensor per day. A clustering key on the timestamp keeps time ranges fast.
  • Three Cassandra 5.0 nodes in Docker with limited Java heap; keyspace with RF = 3, plus a test keyspace at RF = 1 to make partitioning visible.
  • A Python benchmark script loads one year at a time (1.75 million rows each) into both Cassandra and PostgreSQL, then times the same queries.

What we did, and what went wrong

  • Explained the model in the report: the Bigtable data model, Murmur3 partitioning, replication, tunable consistency, write and read paths, and a comparison with HBase and relational systems.
  • Built the cluster and the IoT case study, and kept the real cqlsh and nodetool outputs as evidence.
  • Ran the ten-year benchmark and a PostgreSQL → Cassandra migration with verification scripts.
  • Wrote the report and the presentation in LaTeX.

What went wrong

  • With RF = 3 on three nodes, every node holds 100 % of the data, so replication was visible but partitioning was not. A second keyspace at RF = 1 and nodetool getendpoints showed which node owns which sensor.
  • One laptop cannot host the assignment's full data rate. We lowered the reading interval from 10 seconds to 15 minutes and said so, explaining how it changes the results.

How I checked it

What I wanted to prove, the test I ran, and what I actually saw.

What I wanted to proveThe testWhat I saw
The cluster survives one node downdocker stop cass3, then query Q1 again from cass1 at QUORUMQuery succeeded (two replicas of three still available)
Read time does not grow with historyKey lookups measured after each year loaded, 1 to 10 yearsCassandra flat at 3–5 ms; PostgreSQL 0.3–1.6 ms, slowly rising
Writes and storage favour CassandraSingle-row write throughput; disk usage after 10 years2,504 vs 305 writes/s · 349 MB vs 1,755 MB
Unplanned questions are the weak pointQuery outside the partition keys over 10 yearsCassandra timed out at 12 s (20.7 s when raised); PostgreSQL answered in 16–24 s
Terminal output: node cass3 stopped, query Q1 at consistency QUORUM still returns three rows
Failure test: one node down, the QUORUM read still succeeds.

Result

  • A clear picture of the trade-off: Cassandra keeps planned queries fast whatever the history depth, writes and stores efficiently, but needs every question decided before the first write.
  • Design lesson: in a wide-column database, modeling is about access paths as much as about data.

Limits and next steps

  • All nodes on one machine: nothing is measured about scaling out, Cassandra's main advantage.
  • Timings include the Python drivers and the Docker network.
  • Group work: the report and code are shared by the three authors.

What I would do next

  • Repeat the benchmark on several machines
  • Measure at the original 10-second rate on a smaller time window

Code and documents