Giter Site home page Giter Site logo

k9mil / velocitas Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 242 KB

๐Ÿš„๐Ÿ’จ A simulation of Docker + Nginx load balancing. Built with Go and Fiber.

License: GNU General Public License v3.0

Go 10.53% Dockerfile 3.56% JavaScript 5.94% HTML 3.24% CSS 76.73%
nginx load-balancer docker fiber golang website badgerdb go fibers fiber-framework

velocitas's Introduction

๐Ÿš„๐Ÿ’จ velocitas

Velocity is an open-source horizontal scaling simulation, with a load-balanced multi instance architecture built with Golang + Fiber, Tailwind, Docker + nginx (alongside the demo being hosted on a DigitalOcean droplet). The web-app simply adds 10,000 k:v pairs via BadgerDB. This project was made to play around with docker-compose and nginx as a load balancer, but feel free to use this if you so wish.

Unfortunately, this project cannot be built on a 1GB VM, as the build itself takes > 1,3GB and faults on one of the dependencies required by Fiber:

go build github.com/gofiber/fiber/v2/internal/go-json/encoder/vm: /usr/local/go/pkg/tool/linux_amd64/compile: signal: killed

By looking at /var/log/syslog, we can see that a process is killed, due to using too much memory:

Apr  8 08:54:13 nginx kernel: [  206.696666] Out of memory: Killed process 3181 (compile) total-vm:1331324kB, anon-rss:630496kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:1352kB oom_score_adj:0
Apr  8 08:54:13 nginx kernel: [  206.735462] oom_reaper: reaped process 3181 (compile), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Apr  8 08:54:22 nginx docker.dockerd[937]: time="2022-04-08T08:54:22.654457806Z" level=error msg="copy shim log" error="read /proc/self/fd/14: file already closed"

Therefore, if you're planning to use this, ensure that your machine/VM is at least 1,5GB in memory in order for Golang to compile.

Philosophy

nginx diagram

Below you can see, that docker-compose assigns various colours to each docker instance that holds Fiber, and distributes them appropriately (each hit on the DNS/server is sent to a different docker instance).

instances diagram

Demo

A demo server is available here.

Usage

  1. Simply git clone this particular repository.
  2. cd into the downloaded folder.
  3. Run docker-compose --compatibility up --build

License

Licensed under the MIT License - see the LICENSE file for more details.

velocitas's People

Contributors

k9mil avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

pvillamil

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.