Skip to content

Commit ff02072

Browse files
Created UI feature. Enabled output export.
1 parent 04179f6 commit ff02072

File tree

20 files changed

+2374
-118
lines changed

20 files changed

+2374
-118
lines changed

README.md

Lines changed: 136 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ It simulates real-world usage patterns by generating random data using robust BS
66

77
This tool is a complete refactor of the previous Python version, offering:
88
* **Single Binary:** No complex dependencies or Python environment setup.
9+
* **Interactive Web UI:** A beautiful dashboard for configuring and running workloads and monitoring live telemetry.
910
* **High Concurrency:** Utilizes Go goroutines ("Active Workers") to generate massive load with minimal client-side resource usage.
1011
* **Configuration as Code:** Fully configurable via a simple `config.yaml` file or Environment Variables.
1112
* **Extensive Data Support:** Supports all standard MongoDB BSON data types (ObjectId, Decimal128, Date, Binary, etc.) and realistic data generation via `gofakeit` (supporting complex nested objects and arrays).
@@ -19,7 +20,7 @@ This tool is a complete refactor of the previous Python version, offering:
1920

2021
**Option 1: Download Release**
2122

22-
Navigate to the [Releases] page and download the .tar.gz file matching your operating system.
23+
Navigate to the Releases page and download the .tar.gz file matching your operating system.
2324

2425
1. Download and Extract
2526

@@ -36,7 +37,7 @@ tar -xzvf plgm-darwin-arm64.tar.gz
3637
This project includes a `Makefile` to simplify building and packaging.
3738

3839
```bash
39-
git clone https://github.com/Percona-Lab/percona-load-generator-mongodb.git
40+
git clone [https://github.com/Percona-Lab/percona-load-generator-mongodb.git](https://github.com/Percona-Lab/percona-load-generator-mongodb.git)
4041
cd percona-load-generator-mongodb
4142
go mod tidy
4243

@@ -47,15 +48,96 @@ make build-local
4748
./bin/plgm --help
4849
```
4950

50-
### 2. Configuration & Resources
51+
**Cross-Compilation (Build for different OS)**
52+
53+
If you are preparing binaries for other users (or other servers), use the main build command. This will compile binaries for Linux and Mac and automatically package them into .tar.gz files in the `bin/` folder.
5154

52-
To run the application, you need a configuration file. Depending on whether you want to run the built-in test or your own custom workload, you may also need to create resource folders.
55+
```bash
56+
# Generate all release packages
57+
make build
58+
59+
# Output:
60+
# bin/plgm-linux-amd64.tar.gz
61+
# bin/plgm-darwin-amd64.tar.gz
62+
# bin/plgm-darwin-arm64.tar.gz
63+
```
64+
65+
### 2. Configuration
66+
67+
To run the application you need a configuration file. Depending on whether you want to run the built-in workload or your own custom, you may also need to create resource folders.
5368

5469
**Step A: Get the Config**
5570

56-
Download the [`config.yaml`](./config.yaml) and adjust the `uri` to point to your MongoDB instance.
71+
Download the [`config.yaml`](./config.yaml) and make the necessary adjustments.
72+
73+
### 3. Choose Your Interface
74+
75+
`plgm` can be run completely headless via the CLI, or via a rich interactive Web Dashboard.
76+
77+
* **Run via CLI (Headless):**
78+
```bash
79+
./bin/plgm
80+
```
81+
* **Run via Web UI:**
82+
```bash
83+
./bin/plgm --webui
84+
```
85+
86+
## The Interactive UI
87+
88+
`plgm` features a completely embedded Web UI. It allows you to configure your database connection, upload custom workload schemas, adjust operation ratios, and monitor real-time throughput and latency without ever touching a YAML file. It has the same functionality as the CLI version, but with an awesome UI.
89+
90+
#### 1. Starting the UI
91+
To launch the UI, simply pass the `--webui` flag. The application will start a secure local server and automatically open your default web browser listening on port 9999. You can also set a custom port instead, as shown in the example below:
92+
93+
```bash
94+
./bin/plgm --webui
95+
# Or, set a custom port:
96+
./bin/plgm --webui --webui-port=32000
97+
```
98+
99+
#### 2. Configuration
100+
The UI provides an intuitive tabbed interface to configure every aspect of your workload.
101+
102+
* **Connection:** Set your URI, read preferences, and connection pooling limits. Passwords are never logged and are safely managed via session storage.
103+
104+
![PLGM Configuration UI - Connection Tab](./images/connection.png)
105+
106+
* **Workload & Mix:** Upload your own custom `collections.json` and `queries.json` files directly through the browser, and use visual inputs to ensure your Find/Insert/Update/Delete ratios total exactly 100%. You can also run the default workload by clicking the `Use built-in Default Workload` checkbox.
107+
108+
![PLGM Configuration UI - Connection Tab](./images/workload.png)
109+
110+
![PLGM Configuration UI - Mix Tab](./images/mix.png)
111+
112+
* **Advanced & Raw Injector:** Fine-tune batch sizes, timeouts, or override the standard workload with the ultra-high-performance Raw Injector.
57113

58-
**Step B: Choose Your Workload**
114+
![PLGM Configuration UI - Advanced Tab](./images/advanced.png)
115+
116+
![PLGM Configuration UI - Raw Injector Tab](./images/raw_injector.png)
117+
118+
#### 3. The Observability Dashboard
119+
Once the workload begins, the UI transitions to a real-time observability dashboard.
120+
121+
![PLGM Observability Dashboard (Top)](./images/dashboard_top.png)
122+
![PLGM Observability Dashboard (Bottom)](./images/dashboard_bottom.png)
123+
124+
* **Live Telemetry:** Watch throughput (Ops/sec) and average latency (ms) stream in real-time across four distinct operation categories.
125+
* **Workload Anatomy:** A live-updating donut chart proves that your database is accurately executing the exact operation ratios you configured.
126+
* **Crosshair Sync:** Hovering over a spike on the Throughput chart will instantly highlight the exact same moment in time on the Latency chart.
127+
128+
#### 4. The "Time Machine" Scrubber
129+
If you are running a long benchmark, you might miss a sudden latency spike. The UI stores a running history buffer of the benchmark data.
130+
131+
Simply grab the **Time Machine** slider above the charts and drag it to the left to pause the live feed and "scrub" backward in time. All line charts, sparklines, and numeric values will perfectly synchronize to show you the exact state of the database at that specific historical second. Click **Back to Live** to resume real-time monitoring.
132+
133+
![PLGM Time Machine Feature](./images/time_machine.png)
134+
135+
136+
## CLI
137+
138+
#### 1. Configuration
139+
140+
Once you have configured your connection settings and any other parameters, you can choose your workload.
59141

60142
* **Mode 1: Default Workload (Easiest)**
61143

@@ -71,7 +153,7 @@ Download the [`config.yaml`](./config.yaml) and adjust the `uri` to point to you
71153

72154
> **Important:** If you are running in Custom Mode, the application expects these folders to exist. If the folders are missing, `plgm` will revert to the embedded defaults to prevent a crash, but your custom test **will not run** until the files are in place.
73155
74-
### 3. Run
156+
#### 2. Run
75157

76158
Once configured, run the application:
77159

@@ -80,21 +162,7 @@ Once configured, run the application:
80162
./plgm-linux-amd64
81163
```
82164

83-
**Cross-Compilation (Build for different OS)**
84-
85-
If you are preparing binaries for other users (or other servers), use the main build command. This will compile binaries for Linux and Mac and automatically package them into .tar.gz files in the `bin/` folder.
86-
87-
```bash
88-
# Generate all release packages
89-
make build
90-
91-
# Output:
92-
# bin/plgm-linux-amd64.tar.gz
93-
# bin/plgm-darwin-amd64.tar.gz
94-
# bin/plgm-darwin-arm64.tar.gz
95-
```
96-
97-
#### Usage
165+
#### 3. CLI Usage
98166

99167
To view the full usage guide, including available flags and environment variables, run the help command:
100168

@@ -111,21 +179,25 @@ Examples:
111179

112180
Flags:
113181
-config string
114-
Path to the configuration file (default "config.yaml")
182+
Path to the configuration file (default "config.yaml")
115183
-raw-injector
116-
Enable Raw BSON Injector (High Performance Mode)
184+
Enable Raw BSON Injector (High Performance Mode)
117185
-raw-injector-batch int
118-
Bulk batch size (ops per network round trip) (default 1000)
186+
Bulk batch size (ops per network round trip) (default 1000)
119187
-raw-injector-drop
120-
Drop the collection before starting
188+
Drop the collection before starting
121189
-raw-injector-max-docs int
122-
Maximum number of documents to operate on (default 10000000)
190+
Maximum number of documents to operate on (default 10000000)
123191
-raw-injector-size int
124-
Document size in bytes (default 1024)
192+
Document size in bytes (default 1024)
125193
-raw-injector-type string
126-
Operation: insert, upsert, update, delete, find, mixed (default "insert")
194+
Operation: insert, upsert, update, delete, find, mixed (default "insert")
127195
-version
128-
Print version information and exit
196+
Print version information and exit
197+
-webui
198+
Start the interactive Web UI
199+
-webui-port int
200+
Port for the Web UI (default 9999)
129201

130202
Environment Variables (Overrides):
131203
[Connection]
@@ -136,6 +208,10 @@ Environment Variables (Overrides):
136208
PLGM_REPLICASET_NAME Replica Set name
137209
PLGM_READ_PREFERENCE nearest
138210

211+
[Web UI]
212+
PLGM_WEBUI_ENABLED Start the interactive Web UI (true/false)
213+
PLGM_WEBUI_PORT Port for the Web UI (default: 9999)
214+
139215
[Workload Core]
140216
PLGM_DEFAULT_WORKLOAD Use built-in workload (true/false)
141217
PLGM_COLLECTIONS_PATH Path to collection JSON
@@ -182,8 +258,9 @@ Environment Variables (Overrides):
182258
GOMAXPROCS Go Runtime CPU limit
183259
```
184260

185-
### 2. Default Workload
186-
plgm comes with a built-in default workload useful for immediate testing and get you started right away.
261+
## Default Workload
262+
263+
Regardless of rather you are running PLGM from CLI or UI, it comes with a built-in default workload useful for immediate testing and get you started right away.
187264
```bash
188265
# Edit config.yaml to set your URI, then run:
189266
./bin/plgm
@@ -199,7 +276,7 @@ If you wish to use a different default workload, you can replace these two files
199276
./bin/plgm /path/to/some/custom_config.yaml
200277
```
201278

202-
### 3. Raw Injector Mode (High Performance Hardware Test) Workload
279+
## Raw Injector Mode (High Performance Hardware Test) Workload
203280

204281
The **Raw Injector** is a specialized, ultra-high-performance engine built directly into `PLGM`. Instead of using the standard MongoDB driver structs (which consume CPU and memory for BSON marshaling), the Raw Injector pre-compiles raw BSON byte arrays and performs zero-allocation bitwise mutations in a tight loop.
205282

@@ -209,7 +286,7 @@ Unlike the other workloads PLGM supports, this mode is not configurable. It was
209286

210287
***Important Note on Ops/Sec: In Raw Injector mode, the printed Ops/Sec refers to the number of documents processed, not the number of network commands. For example, if your batch size is 1,000, and plgm reports 50,000 Ops/Sec, it is executing 50 bulk network commands per second.***
211288

212-
#### Configuration
289+
### Configuration
213290

214291
You can configure the Raw Injector via `config.yaml` or directly via CLI flags/environment variables. These are the available options:
215292

@@ -239,15 +316,15 @@ Environment variables:
239316
PLGM_INJECTOR_COLLECTION Collection name
240317
```
241318

242-
#### Modes of Operation (type)
319+
### Modes of Operation (type)
243320

244321
* insert: Floods the database with new documents. Automatically pre-splits chunks if sharding is enabled.
245322
* find / update / delete: Operates on the existing data seeded by an insert run.
246323
* upsert: Fires upsert commands, creating documents if they don't exist.
247324
* mixed: Runs a randomized distribution of reads, inserts, updates, and deletes simultaneously.
248325

249326

250-
#### Running via CLI
327+
### Running via CLI
251328
You can bypass the YAML config entirely and trigger a raw injection test purely through flags:
252329

253330
##### Run a pure insert flood, dropping existing data, with 4KB documents
@@ -381,7 +458,7 @@ PLGM_INJECTOR=true PLGM_INJECTOR_TYPE=mixed PLGM_DURATION=30s ./plgm
381458
382459
</details>
383460
384-
### 4. Additional Workloads
461+
## Additional Workloads
385462
386463
You will find additional workloads that you can use as references to benchmark your environment in cases where you prefer not to provide your own collection definitions and queries. However, if your goal is to test your application accurately, we strongly recommend creating collection definitions and queries that match those used by your application.
387464
@@ -391,7 +468,7 @@ The additional collection and query definitions can be found here:
391468
* [queries](./resources/queries/)
392469
393470
394-
### 5. Workload Configuration & Loading
471+
### Workload Configuration & Loading
395472
396473
You can supply your own collections and queries using the `PLGM_COLLECTIONS_PATH` and `PLGM_QUERIES_PATH` environment variables (or the corresponding config file fields).
397474
@@ -443,8 +520,15 @@ You can override any setting in `config.yaml` using environment variables. This
443520
| `direct_connection` | `PLGM_DIRECT_CONNECTION` | Force direct connection (bypass topology discovery) | `true` |
444521
| `replicaset_name` | `PLGM_REPLICASET_NAME` | Replica Set name (required for sharded clusters/RS) | `rs0` |
445522
| `read_preference` | `PLGM_READ_PREFERENCE` | By default, an application directs its read operations to the primary member in a replica set. You can specify a read preference to send read operations to secondaries. | `nearest` |
446-
| `username` | `PLGM_USERNAME` | Database User | `admin` |
447-
| ***can not be set via config*** | `PLGM_PASSWORD` | Database Password (if not set, plgm will prompt) | `password123` |
523+
| `username` | `PLGM_USERNAME` | Database User | `admin` |
524+
| ***can not be set via config*** | `PLGM_PASSWORD` | Database Password (if not set, plgm will prompt) | `password123` |
525+
| **Web UI** | | | |
526+
| `enabled` | `PLGM_WEBUI_ENABLED` | Force launch the Web UI | `true` |
527+
| `port` | `PLGM_WEBUI_PORT` | Port for the Web UI | `9999` |
528+
| **Metrics Export** | | | |
529+
| `csv_export_enabled` ||Continuously stream workload throughput metrics to a CSV file| `false` |
530+
| `csv_export_append` ||If true, appends to the file. If false, overwrites it.| `false` |
531+
| `csv_export_path` ||Path and metrics file name| `/tmp/plgm_metrics_export.csv` |
448532
| **Workload Control** | | | |
449533
| `concurrency` | `PLGM_CONCURRENCY` | Number of active worker goroutines | `50` |
450534
| `duration` | `PLGM_DURATION` | Test duration (Go duration string) | `5m`, `60s` |
@@ -502,6 +586,7 @@ When executed, plgm performs the following steps:
502586
4. **Reporting:**
503587
* Outputs a real-time status report every N seconds (configurable).
504588
* Prints a detailed summary table at the end of the run.
589+
* Export output to csv (off by default)
505590
506591
### Sample Output
507592
@@ -646,15 +731,15 @@ You can fine-tune plgm internal behavior by adjusting the parameters in `config.
646731
#### Workload Type
647732
By default, the tool comes preconfigured with the following workload distribution:
648733
649-
| Operation | Percentage |
734+
| Operation | Percentage |
650735
| :--- | :--- |
651-
| Find | 50% |
652-
| Update | 20% |
653-
| Delete | 10% |
654-
| Insert | 5% |
736+
| Find | 50% |
737+
| Update | 20% |
738+
| Delete | 10% |
739+
| Insert | 5% |
655740
| Bulk Inserts | 5% |
656-
| Aggregate | 5% |
657-
| Transaction | 5% |
741+
| Aggregate | 5% |
742+
| Transaction | 5% |
658743
659744
You can modify any of the values above to run different types of workloads.
660745
@@ -739,7 +824,7 @@ Because custom_params are directly injected into the MongoDB connection string,
739824
740825
Example config.yaml for TLS:
741826
742-
```YAML
827+
```yaml
743828
custom_params:
744829
compressors: "none"
745830
tls: true
@@ -752,3 +837,6 @@ Further configuration and examples specific to [Kubernetes environments setup wi
752837
***Note: Ensure you remove tls: false from your URI if you are using tls: true in custom_params, as the MongoDB Go driver will return a fatal error if conflicting security parameters are provided.***
753838
754839
840+
# Disclaimer
841+
842+
This application is not supported by Percona. It has been provided as a community contribution and is not covered under any Percona services agreement.

0 commit comments

Comments
 (0)