Skip to content

tech-inspire/scylladb-cluster-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScyllaDB Cluster Docker Example

An example ScyllaDB cluster setup for the InSpire Posts Service:

  • 5 ScyllaDB nodes
  • Prometheus for scraping metrics

1. Start the Cluster

docker-compose up -d
Node CQL Port REST API Port
scylla-node1 19042 19100
scylla-node2 19043 19101
scylla-node3 19044 19102
scylla-node4 19045 19103
scylla-node5 19046 19104

2. Verify All Nodes Are Running

docker exec -it scylla-node1 nodetool status                         

Example output:

Datacenter: DC1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address      Load      Tokens Owns Host ID                              Rack 
UN 192.168.97.2 607.50 KB 256    ?    94e070c4-ba13-48ce-95a9-ba329100e672 Rack1
UN 192.168.97.3 612.60 KB 256    ?    6e58defa-8717-4686-bd82-562fea6d640b Rack1
UN 192.168.97.4 574.76 KB 256    ?    3d07157f-189d-4212-83f0-1cee2bd433ff Rack1
UN 192.168.97.6 602.65 KB 256    ?    a89a542c-c0b0-4af5-b9c4-732de7f64f67 Rack1
UN 192.168.97.7 567.55 KB 256    ?    4b7a37e0-aca3-4531-939f-6943d7066c2e Rack1

3. Create a Keyspace and posts Table

docker exec scylla-node1 cqlsh -f migrations/create_posts.cql

4. Insert Test Data

docker exec scylla-node1 cqlsh -f migrations/insert_data.cql

5. Verify Data Distribution Across Nodes

docker exec -it scylla-node2 nodetool status --keyspace posts_service

You should see all 5 nodes with effective token ownership.

Datacenter: DC1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address      Load      Tokens Owns (effective) Host ID                              Rack 
UN 192.168.97.2 607.50 KB 256    59.8%            94e070c4-ba13-48ce-95a9-ba329100e672 Rack1
UN 192.168.97.3 581.48 KB 256    61.2%            6e58defa-8717-4686-bd82-562fea6d640b Rack1
UN 192.168.97.4 574.76 KB 256    61.8%            3d07157f-189d-4212-83f0-1cee2bd433ff Rack1
UN 192.168.97.6 602.65 KB 256    56.8%            a89a542c-c0b0-4af5-b9c4-732de7f64f67 Rack1
UN 192.168.97.7 567.55 KB 256    60.5%            4b7a37e0-aca3-4531-939f-6943d7066c2e Rack1

6. Run Read Queries

cat migrations/read_data.cql | docker exec -i scylla-node1 cqlsh

Example result:

(10 rows)

 post_id                              | author_id                            | created_at                      | description     | image_height | image_url                    | image_width
--------------------------------------+--------------------------------------+---------------------------------+-----------------+--------------+------------------------------+-------------
 b6c0e97b-6dfa-4001-9319-957ed6f18464 | 95c867bd-214c-4ebe-bc85-38f48a1538c1 | 2025-05-16 22:11:32.541000+0000 | Instagram style |         1350 | https://example.com/img7.jpg |        1080
 d2d68894-a0e7-4618-adf9-aea24db859a2 | 47bb52ba-bac6-4179-a0de-8fe8e4d9aed4 | 2025-05-16 22:11:32.539000+0000 |     Profile pic |         1080 | https://example.com/img2.jpg |        1080
 ...

You can also run queries manually (see read_data.cql):

SELECT * FROM posts WHERE post_id = <uuid>;

SELECT * FROM posts WHERE image_width = 1080 ALLOW FILTERING;

SELECT * FROM posts WHERE image_height = 1080 ALLOW FILTERING;

SELECT * FROM posts WHERE created_at > 1715731200000 ALLOW FILTERING;

Destroy the Cluster

docker-compose down --volumes
docker-compose rm -f

Prometheus + Grafana

Prometheus is exposed on port 19090 and scrapes metrics from all ScyllaDB nodes. See dashboard.json for an example Grafana dashboard configuration.


Contributing

Feel free to open issues or submit pull requests to improve this setup. To contribute:

  1. Fork the repository
  2. Create a new branch: git checkout -b my-feature
  3. Commit your changes
  4. Push to your fork and submit a PR

TODO

  • Grafana dashboard
  • Add client connection example

About

ScyllaDB Cluster Docker Example with Prometheus Monitoring

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published