https://github.com/karolsluszniak/clustered_queue_and_pool-phoenix-1.6
Phoenix 1.6 example app with persistent & clustered transaction queue backed by Oban, clustered wallet pool and ready-to-go clustering-enabled Fly deployment.
https://github.com/karolsluszniak/clustered_queue_and_pool-phoenix-1.6
clustering elixir flydotio oban phoenix
Last synced: about 2 months ago
JSON representation
Phoenix 1.6 example app with persistent & clustered transaction queue backed by Oban, clustered wallet pool and ready-to-go clustering-enabled Fly deployment.
- Host: GitHub
- URL: https://github.com/karolsluszniak/clustered_queue_and_pool-phoenix-1.6
- Owner: karolsluszniak
- License: mit
- Created: 2021-12-27T19:57:00.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-27T20:28:39.000Z (almost 4 years ago)
- Last Synced: 2025-08-10T23:42:58.615Z (about 2 months ago)
- Topics: clustering, elixir, flydotio, oban, phoenix
- Language: Elixir
- Homepage:
- Size: 145 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Phoenix 1.6 example app with clustered queue and pool
Sponsored by [Hawku](https://hawku.com).
## Features
This app builds on top of [Phoenix 1.6 example app with live auth and avatars](https://github.com/karolsluszniak/live_auth_and_avatars-phoenix-1.6) 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 requiredFollow 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](https://someapp.fly.dev)
* Increase and decrease the node count with `fly scale count N` and observe the transactions pageNow you can visit [`localhost:4000`](http://localhost:4000) or [`localhost:4001`](http://localhost:4001) from your browser.