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#
- Install the required dependencies:
npm install
# or
yarn install
- 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 statusstop: Stop the simulationhelp: Show available commandsquit: Exit the program
How It Works#
The simulator:
- Connects multiple WebSocket clients to your Phoenix application
- Authenticates each client using tokens from
tokens.json - Joins the bookmark channel for each client
- Periodically creates random bookmarks using realistic sample data
- 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 setupto install and setup dependencies - Start Phoenix endpoint with
mix phx.serveror inside IEx withiex -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#
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix