Git Product home page Git Product logo

swarm-demo's Introduction

Docker Swarm Demo

Visualizes how Docker nodes work together in a distributed environment.
This is a demo project for the trivago code workshop.

This will create the following setup:

                                         +--------------+
                                         |              |
                                   +----->   Server 1   |
                                   |     |              |
                                   |     +--------------+
                                   |                     
+------------+    +------------+   |     +--------------+
|            |    |            |   |     |              |
|  Client    +---->   Swarm    +--------->   Server 2   |
|            |    |            |   |     |              |
+------------+    +------------+   |     +--------------+
                                   |                     
                                   |     +--------------+
                                   |     |              |
                                   +----->   Server 3   |
                                         |              |
                                         +--------------+

The servers are golang webservers that take an int and return true if the int is a prime number and false otherwise.
The traffic to the containers is load-balanced with HAproxy.
Swarm is used for scaling the number of webservers.

Usage

Starting the cluster

First start haproxy and consul with ./start_haproxy.sh. You can add new servers with ./start_primeserver.sh.
This will create a new instance of the primeserver container.

Connecting with a client

After that you can run the clients either locally or in another container.
E.g. to check each number from 1 to 1000 if it is prime in batches of 100, run:

go run primeclient.go --host=hostname --start=1 --stop=1000 --step=100

Of course you can start many clients at the same time to create more load.

Start metrics backend

To get an idea of the current cluster status, you can collect some metrics.
For that you can start the metrics backend, which is completely independent from the application.
You can enable and disable it at any time.

Start it with docker-compose up from the respective folder.
To make it work across hosts, also add the following entry to the /etc/hosts on cluster every machine:

127.0.0.1 influxdb

Please adjust the IP to the host where InfluxDB is running.

Maintainers

@jsacha @mendler

swarm-demo's People

Contributors

jakubsacha avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

sm-newtech

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.