# ScyllaDB Cluster

> High-performance Cassandra-compatible NoSQL database written in C++.

- Category: Database Stacks
- Difficulty: intermediate
- Components: scylladb
- Tags: scylladb, cassandra, nosql, wide-column, performance
- Source: https://docker.recipes/databases/scylladb

## Overview

ScyllaDB is a high-performance NoSQL database written in C++ that provides full compatibility with Apache Cassandra while delivering significantly better performance characteristics. Originally developed by Avi Kivity and the team at ScyllaDB, it reimplements Cassandra's functionality using modern C++ techniques and a shard-per-core architecture that eliminates the overhead of Java Virtual Machine garbage collection. ScyllaDB maintains wire protocol compatibility with Cassandra, meaning existing applications and drivers can connect without modification while benefiting from 10x better throughput and dramatically reduced P99 latencies. This cluster configuration deploys a two-node ScyllaDB setup that demonstrates distributed wide-column storage capabilities with automatic data replication and partition tolerance. The nodes communicate through a dedicated bridge network and use seed-based discovery to form a cohesive cluster that can handle node failures gracefully. The configuration includes memory and CPU constraints suitable for development environments while maintaining the core distributed database functionality that makes ScyllaDB attractive for production workloads. This setup is ideal for developers migrating from Cassandra who want to experience ScyllaDB's performance benefits, teams building real-time analytics platforms that require low-latency data access, and organizations evaluating modern NoSQL alternatives that can scale horizontally while maintaining strong consistency guarantees.

## Features

- Cassandra CQL compatibility with existing drivers and applications
- C++ implementation delivering 10x better performance than Java-based Cassandra
- Shard-per-core architecture eliminating JVM garbage collection overhead
- Automatic cluster formation using seed-based node discovery
- Multi-node data replication with configurable consistency levels
- Wide-column data model supporting flexible schema evolution
- Built-in nodetool compatibility for cluster monitoring and maintenance
- DynamoDB-compatible API support for cloud migration scenarios

## Use cases

- Migrating existing Cassandra applications to gain 10x performance improvements
- Real-time analytics platforms requiring sub-millisecond query response times
- IoT data ingestion systems handling millions of time-series data points
- Gaming backends storing player profiles and session data with low latency
- Content management systems serving personalized recommendations at scale
- Financial services applications tracking transactions with high availability requirements
- Development environments for testing distributed database applications locally

## Prerequisites

- Minimum 4GB RAM available to Docker (750MB allocated per node plus overhead)
- Docker Engine 20.10+ with Docker Compose v2 support
- Basic understanding of NoSQL concepts and CQL query language
- Familiarity with distributed database concepts like eventual consistency
- Network ports 9042 (CQL) and 9160 (Thrift) available on host system
- SSD storage recommended for optimal performance in production deployments

## docker-compose.yml

```yaml
services:
  scylla1:
    image: scylladb/scylla:latest
    container_name: scylla1
    command: --seeds=scylla1 --smp 1 --memory 750M --overprovisioned 1
    volumes:
      - scylla1_data:/var/lib/scylla
    ports:
      - "9042:9042"
      - "9160:9160"
    networks:
      - scylla-network

  scylla2:
    image: scylladb/scylla:latest
    container_name: scylla2
    command: --seeds=scylla1 --smp 1 --memory 750M --overprovisioned 1
    volumes:
      - scylla2_data:/var/lib/scylla
    depends_on:
      - scylla1
    networks:
      - scylla-network

volumes:
  scylla1_data:
  scylla2_data:

networks:
  scylla-network:
    driver: bridge
```

## .env

```bash
# ScyllaDB optimized for containers
```

## Usage notes

- Docs: https://docs.scylladb.com/
- CQL port 9042 | Thrift port 9160 (legacy)
- Connect: docker exec -it scylla1 cqlsh
- 10x faster than Apache Cassandra - C++ vs Java
- Drop-in Cassandra replacement - same CQL and drivers
- Monitor: docker exec -it scylla1 nodetool status

## Troubleshooting

- Container exits with 'Not enough memory' error: Increase Docker's memory limit to at least 4GB total
- CQL connection refused on port 9042: Wait 60-90 seconds for cluster initialization to complete
- Nodes show as DOWN in nodetool status: Check inter-node connectivity on the scylla-network bridge
- High CPU usage during startup: Normal behavior as ScyllaDB performs auto-tuning and optimization
- Volume mount permission errors: Ensure Docker has proper access to volume mount directories
- Seed node discovery failures: Verify scylla1 container starts first and maintains stable networking

