spark-cassandra-connector can achieve data locality by running the tasks in the same node that the actual data is. How this works is if the Cassandra and spark are different services in a Swarm cluster? Spark containers and Cassandra containers have different IP addresses in this case.