Skip to content

k9mil/velocitas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš„๐Ÿ’จ 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.