Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

10/23/2020

Reading time:1 min

DataStax-Examples/dc-latency-checker

by DataStax-Examples

This a simple program that can be run to check the difference in latencies between 2 data centers and calculates an ongoing average.Contributor(s): Patrick CallaghanObjectivesObserve the latency difference between nodes in a cluster spanning two different data centers.Project LayoutMain.java - Runs a test with either a 1KB or 5 MB payload.How this WorksRunning Main.java with either a 1KB payload with 1 second pause or 5MB payload with 3 second pause (with -Dfile=bigfile5M -DpauseInSeconds=3) will provide output of latencies in ms. Also MovingAverage.java will calculate the ongoing average.Setup and RunningPrerequisitesJava 8A DSE cluster running across two dcs (at least 2 nodes)Maven to compile and run codeRunning1KB payload testTo run the simple test with a 1KB payload and pause time of 1 second, execute the followingmvn clean compile exec:java -Dexec.mainClass="com.datastax.test.Main" -DcontactPoints=<localdc-ip> -Dlocaldc=<localdc> -Dremotedc=<remotedc>5MB payload testTo use a larger 5MB payload and change the pause time to 3 seconds, add the file and pauseInSeconds arguments, for examplemvn clean compile exec:java -Dexec.mainClass="com.datastax.test.Main" -DcontactPoints=<localdc-ip> -Dlocaldc=<localdc> -Dremotedc=<remotedc> -Dfile=bigfile5M -DpauseInSeconds=3You can add pass any file to simulate your payload.

Illustration Image

This a simple program that can be run to check the difference in latencies between 2 data centers and calculates an ongoing average.

Contributor(s): Patrick Callaghan

Objectives

Observe the latency difference between nodes in a cluster spanning two different data centers.

Project Layout

  • Main.java - Runs a test with either a 1KB or 5 MB payload.

How this Works

Running Main.java with either a 1KB payload with 1 second pause or 5MB payload with 3 second pause (with -Dfile=bigfile5M -DpauseInSeconds=3) will provide output of latencies in ms. Also MovingAverage.java will calculate the ongoing average.

Setup and Running

Prerequisites

  • Java 8
  • A DSE cluster running across two dcs (at least 2 nodes)
  • Maven to compile and run code

Running

  • 1KB payload test

To run the simple test with a 1KB payload and pause time of 1 second, execute the following

mvn clean compile exec:java -Dexec.mainClass="com.datastax.test.Main" -DcontactPoints=<localdc-ip> -Dlocaldc=<localdc> -Dremotedc=<remotedc>
  • 5MB payload test

To use a larger 5MB payload and change the pause time to 3 seconds, add the file and pauseInSeconds arguments, for example

mvn clean compile exec:java -Dexec.mainClass="com.datastax.test.Main" -DcontactPoints=<localdc-ip> -Dlocaldc=<localdc> -Dremotedc=<remotedc> -Dfile=bigfile5M -DpauseInSeconds=3

You can add pass any file to simulate your payload.

Related Articles

examples
cassandra
datastax

GitHub - datastaxdevs/workshop-betterreads: Clone of Good Reads using Spring and Cassandra

datastaxdevs

12/2/2023

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

examples