This is a Scala Sbt Akka Cluster project that demonstrates how to setup Akka Cluster Sharding on the example of the sea battle game server.
This project builds up to examples of
The project has the load test in the following GitHub repo sea-battle-load-test
$ sbt compile
$ sbt test
This script runs MySQL database server and apps in containers :
- node1 with API route and shards
- node2 with shards
$ ./build_deploy_local.sh
Applications will start and see each other the cluster will start successfully
- Cluster Node [akka://ActorSystem@node2:2552] - Welcome from [akka://ActorSystem@node1:2551]
- Member is Up: akka://ActorSystem@node1:2551
- Member is Joined: akka://ActorSystem@node2:2552
- Member is Up: akka://ActorSystem@node2:2552
Akka Event Sourcing Actors uses a database to store events and snapshots, during application startup we will see in the log
- Database initialized successfully
If the application failed to connect to the database server, we will see the corresponding message and reason in the log
- An error occurred while initializing the database: ...
You can call GRPC API methods manualy with grpcurl util. By default, API port is 8080.
grpcurl \
-d '{"player1": {"id": "4e0453ee-c7ba-11ec-9d64-0242ac120002"}, "player2": {"id": "541042b6-c7ba-11ec-9d64-0242ac120002"}}'
-plaintext \
-import-path /home/capdev/Projects/sea-battle/src/main/protobuf \
-proto battle.proto \
localhost:8080 battle.BattleService/start
if you want more secondary nodes with shards, you need add :
node3:
build: .
environment:
- ARTERY_HOST=node3
- SEED1_HOST=node1
- SEED1_PORT=2551
- SEED2_HOST=node2
- SEED2_PORT=2552
- DB_HOST=mysql