+75
README.md
+75
README.md
···
1
+
# Bookmark Traffic Simulator
2
+
3
+
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.
4
+
5
+
## Prerequisites
6
+
7
+
- Node.js (v14 or later)
8
+
- npm or yarn
9
+
10
+
## Installation
11
+
12
+
1. Install the required dependencies:
13
+
14
+
```bash
15
+
npm install
16
+
# or
17
+
yarn install
18
+
```
19
+
20
+
2. Add your authentication tokens to `tokens.json`. These tokens should be taken from actual authenticated users in your Phoenix application:
21
+
22
+
```json
23
+
[
24
+
"your_auth_token_1",
25
+
"your_auth_token_2",
26
+
"your_auth_token_3"
27
+
]
28
+
```
29
+
30
+
You can get authentication tokens from your Phoenix application's profile page.
31
+
32
+
## Usage
33
+
34
+
Run the simulator with default settings:
35
+
36
+
```bash
37
+
node bookmark_simulator.js
38
+
```
39
+
40
+
Or customize the simulation with command-line options:
41
+
42
+
```bash
43
+
node bookmark_simulator.js --clients 10 --min-interval 1000 --max-interval 5000 --duration 300
44
+
```
45
+
46
+
### Command-line Options
47
+
48
+
- `-e, --endpoint <url>`: WebSocket endpoint URL (default: ws://localhost:4000/socket)
49
+
- `-c, --clients <number>`: Number of clients to simulate (default: 5)
50
+
- `-m, --min-interval <ms>`: Minimum interval between bookmarks in ms (default: 2000)
51
+
- `-M, --max-interval <ms>`: Maximum interval between bookmarks in ms (default: 10000)
52
+
- `-d, --duration <seconds>`: Duration to run the simulation, 0 for unlimited (default: 60)
53
+
- `-v, --verbose`: Enable verbose logging (default: false)
54
+
55
+
### Interactive Commands
56
+
57
+
Once the simulator is running, you can use these commands:
58
+
59
+
- `status`: Show current simulation status
60
+
- `stop`: Stop the simulation
61
+
- `help`: Show available commands
62
+
- `quit`: Exit the program
63
+
64
+
## How It Works
65
+
66
+
The simulator:
67
+
68
+
1. Connects multiple WebSocket clients to your Phoenix application
69
+
2. Authenticates each client using tokens from `tokens.json`
70
+
3. Joins the bookmark channel for each client
71
+
4. Periodically creates random bookmarks using realistic sample data
72
+
5. Reports statistics on the bookmarks created
73
+
74
+
You should see the generated bookmarks appearing in real-time in your Phoenix application's firehose view.
75
+
1
76
# Tasty
2
77
3
78
To start your Phoenix server: