this repo has no description
Elixir 59.5%
JavaScript 24.2%
HTML 11.2%
CSS 1.9%
Python 1.3%
Other 1.8%
12 1 0

Clone this repository

https://tangled.org/bobbby.online/tasty_phx
git@tangled.org:bobbby.online/tasty_phx

For self-hosted knots, clone URLs may differ based on your setup.

README.md

Bookmark Traffic Simulator#

This tool simulates multiple clients connecting to your Phoenix application and creating bookmarks. It's designed to generate realistic traffic for testing the bookmarks firehose feature.

Prerequisites#

  • Node.js (v14 or later)
  • npm or yarn

Installation#

  1. Install the required dependencies:
npm install
# or
yarn install
  1. Add your authentication tokens to tokens.json. These tokens should be taken from actual authenticated users in your Phoenix application:
[
  "your_auth_token_1",
  "your_auth_token_2",
  "your_auth_token_3"
]

You can get authentication tokens from your Phoenix application's profile page.

Usage#

Run the simulator with default settings:

node bookmark_simulator.js

Or customize the simulation with command-line options:

node bookmark_simulator.js --clients 10 --min-interval 1000 --max-interval 5000 --duration 300

Command-line Options#

  • -e, --endpoint <url>: WebSocket endpoint URL (default: ws://localhost:4000/socket)
  • -c, --clients <number>: Number of clients to simulate (default: 5)
  • -m, --min-interval <ms>: Minimum interval between bookmarks in ms (default: 2000)
  • -M, --max-interval <ms>: Maximum interval between bookmarks in ms (default: 10000)
  • -d, --duration <seconds>: Duration to run the simulation, 0 for unlimited (default: 60)
  • -v, --verbose: Enable verbose logging (default: false)

Interactive Commands#

Once the simulator is running, you can use these commands:

  • status: Show current simulation status
  • stop: Stop the simulation
  • help: Show available commands
  • quit: Exit the program

How It Works#

The simulator:

  1. Connects multiple WebSocket clients to your Phoenix application
  2. Authenticates each client using tokens from tokens.json
  3. Joins the bookmark channel for each client
  4. Periodically creates random bookmarks using realistic sample data
  5. Reports statistics on the bookmarks created

You should see the generated bookmarks appearing in real-time in your Phoenix application's firehose view.

Tasty#

To start your Phoenix server:

  • Run mix setup to install and setup dependencies
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

Now you can visit localhost:4000 from your browser.

Ready to run in production? Please check our deployment guides.

Learn more#