Giter Site home page Giter Site logo

karolsluszniak / clustered_queue_and_pool-phoenix-1.6 Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 148 KB

Phoenix 1.6 example app with persistent & clustered transaction queue backed by Oban, clustered wallet pool and ready-to-go clustering-enabled Fly deployment.

License: MIT License

Elixir 85.18% Dockerfile 0.37% CSS 7.15% JavaScript 0.98% HTML 5.86% Shell 0.45%
elixir phoenix clustering oban flydotio

clustered_queue_and_pool-phoenix-1.6's Introduction

Phoenix 1.6 example app with clustered queue and pool

Sponsored by Hawku.

Features

This app builds on top of Phoenix 1.6 example app with live auth and avatars to play with clustering and specifically with distributed Erlang/Elixir, Oban and libcluster to implement the following features:

  • Persistent & clustered transaction queue backed by Oban - each transaction added to the queue is persisted to PostgreSQL database with ACID guarantees and the queue is drained across the entire cluster, all thanks to Oban
  • Clustered wallet pool - wallets are divided equally between all nodes in the cluster, with each node maintaining a process pool for its set of wallets and adjusting the Oban transactions queue for concurrency allowing to use all wallets
  • Ready-to-go clustering-enabled Fly deployment - including all the config required for app to build the production image, deploy it to Fly, connect the cluster using Fly private networking and use IPv6 for endpoint and database as required

Follow the commit history to see how each was implemented.

Usage

To start the server:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

To start with local clustering:

  • Start node a with PORT=4000 SERVER=1 iex --sname a -S mix
  • Start node b with PORT=4001 SERVER=1 iex --sname b -S mix

To deploy to fly

  • Create your own app with fly apps create someapp
  • Fill the name in fly.toml as app = someapp
  • Ensure PostgreSQL is there with fly postgres create and fly postgres attach
  • Deploy with fly deploy and visit your app at someapp.fly.dev
  • Increase and decrease the node count with fly scale count N and observe the transactions page

Now you can visit localhost:4000 or localhost:4001 from your browser.

clustered_queue_and_pool-phoenix-1.6's People

Contributors

karolsluszniak avatar

Stargazers

Saúl Ernesto avatar

Watchers

James Cloos avatar  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.