Giter Club home page Giter Club logo

akka-cluster-playground's Introduction

Akka Cluster Playground

Tinkering with Akka Cluster

This is a toy application developed to play a bit with Akka Cluster. It is based on the sample repo provided by Akka, and on the official documentation. Do you want to play with it? Feel free to contribute! ๐Ÿ˜„

Running

The project is "docker-first", so we need to create the docker images to run using sbt Native Packager. Run the command sbt docker:publishLocal, it will create the image elleflorio/akka-cluster-playground.

Once you have the image, type docker-compose up. Docker compose will run a seed node along with node1 and node2.

API

I integrated Akka HTTP, so you can interact with the cluster using the following REST API. The port for the nodes are the following:

  • seed: 8000
  • node1: 8001
  • node2: 8002

Health

Check if the nodes are up and running calling a /health endpoint:

GET http://localhost:{{port}}/health

Response:

OK

Members

Check the members inside the cluster using the /status/members endpoint:

GET http://localhost:{{port}}/status/members

Response:

[
    "akka.tcp://cluster-playground@node1:1600",
    "akka.tcp://cluster-playground@node2:1600",
    "akka.tcp://cluster-playground@seed:2552"
]

Fibonacci

Ask for the computation of Fibonacci number n with the /process/fibonacci/n endpoint:

GET http://localhost:{{port}}/process/fibonacci/10

Response:

{
    "nodeId": "seed",
    "result": 55
}

The nodeId represents the node where the processor that executed the computation is running.

Cluster Aware Routers

The cluster uses Cluster Aware Routers for load balancing, with a round-robin strategy. You can verify this asking for the Fibonacci number computation to a random node. Everytime the nodeId in the response will be different, following a round-robin strategy.

That's it! Enjoy! ๐Ÿ˜

akka-cluster-playground's People

Contributors

elleflorio avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.