Skip to content

Commit dfc5751

Browse files
authored
COMPASS-319 - Added RTSS README (#746)
1 parent 8554618 commit dfc5751

File tree

1 file changed

+74
-4
lines changed

1 file changed

+74
-4
lines changed

src/internal-packages/server-stats/README.md

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,82 @@
11
# Compass Real Time Server Stats Package
22

3-
Provides functionality shown in the RTSS zero state view.
3+
The RTSS page is compromised of 3 main elements:
4+
- The "hot collections" table based on the `top` command
5+
- The "slow operations" table based on the `currentOp` command
6+
- Four charts based on the `serverStatus` command
47

5-
## Available Resources in the App Registry
8+
# Components
69

7-
### Components
10+
The top-level component for the RTSS view is the `performance-component`, which contains the `time-and-pause-button` (the pause button and timer at the top of the page), `dberror-component`, and the lists and charts components.
11+
12+
## Lists
13+
The lists are contained in the `server-stats-lists-component`, which contains both `top-component` and the `current-op-component`. The Slow Operations table also includes the `detailview-component`, which shows the raw data from the `currentOp` command.
14+
15+
## Charts
16+
There `server-stats-graphs-component` contains four instances of `chart-component`, one for each chart. Each `chart-component` contains a `D3Component`, which is a wrapper class around the reusable d3 chart defined in the `d3` folder.
17+
18+
# Stores
19+
20+
## Charts
21+
The `server-stats-graphs-store` listens to the `pollServerStats`, `pause`, and `restart` actions. When `pollServerStats` is triggered, about once a second, [the serverStatus command](https://docs.mongodb.com/manual/reference/command/serverStatus/#dbcmd.serverStatus) is called on the DataService client. The results of the command is then passed to each of the four graph stores, which are named after the field of the result that they display. Each of the chart stores listen to the `ServerStatsStore` and the `restart` action.
22+
23+
The `restart` action clears the stored data in each of the chart stores and the `pause` action stops new data from being displayed but continues to collect data.
24+
25+
The charts' X axes are the time from [the "localTime" field](https://docs.mongodb.com/manual/reference/command/serverStatus/#serverstatus.localTime) and the Y axes vary depending on the graph. Each graph store selects data to send to it's instance of `chart-component` where it is put into a d3 chart.
26+
27+
Because the Network and Operations graphs show deltas, all graphs are shown with a 1-second delay. Chart lines will not draw if a pause of more than 1.5 seconds is detected between data points. This results in charts that may not be contiguous but will never show back-in-time behavior due to interpolation.
28+
29+
### Memory
30+
The `mem-store` gets data from [the "mem" field](https://docs.mongodb.com/manual/reference/command/serverStatus/#mem). The Y values are the current memory usage from `serverStatus.mem.vsize` (virtual), `serverStatus.mem.resident`, and `serverStatus.mem.mapped` converted to GB.
31+
32+
### Network
33+
The `network-store` gets data from [the "network" field](https://docs.mongodb.com/manual/reference/command/serverStatus/#serverstatus.network). The Y values are the network usage **_deltas_** from `serverStatus.network.bytesIn` and `serverStatus.network.bytesOut` in KB, i.e. the increase or decrease in network usage since the previous second.
34+
35+
### Operations
36+
The `opcounters-store` gets data from [the "opcounters" field](https://docs.mongodb.com/manual/reference/command/serverStatus/#opcounters). The Y values are the operation count **_deltas_** from `serverStatus.opCounters.insert` / `query` / `update` / `delete` / `command` / `getmore`. This graph shows the increase or decrease in the number of each operation per second.
37+
38+
### Reads and Writes
39+
40+
The `globallock-store` gets data from [the "globallock" field](https://docs.mongodb.com/manual/reference/command/serverStatus/#server-status-global-lock). The Y values are the current number of operations from `serverStatus.globalLock.activeClients.readers`(active reads) `serverStatus.globalLock.activeClients.writers` (active writes), `serverStatus.globalLock.currentQueue.readers` (queued reads) and `serverStatus.globalLock.currentQueue.writers` (queued writes).
41+
42+
## Hot Collections
43+
The `top-store` listens to `pollTop`, `pause`, and `restart` actions. When `pollTop` is triggered, it calls [the top command](https://docs.mongodb.com/master/reference/command/top) on the DataService and passes the list of hottest (i.e. most used, or **greatest system load**) to the `top-component`. The order of the list is calculated to be consistent with how the Cloud team and `mongotop` rank their hot collections.
44+
45+
The `restart` action clears the stored data in each of the chart stores and the `pause` action stops new data from being displayed but continues to collect data.
46+
47+
#### Variables:
48+
Each data point _x_ includes the fields `total`, `readLock`, and `writeLock`.
49+
50+
_x<sub>i</sub>_ = data point at current time
51+
52+
_x<sub>i-1</sub>_ = data point at 1 interval before current time.
53+
54+
_P_ = interval in microseconds. We can calculate interval with _x<sub>i</sub> - x<sub>i-1</sub>_ but we already know what it will be since we are polling once/second.
55+
56+
_N_ = number of cores on the machine. This information is from `buildInfo` and accessed through `app.instance.host.cpu_cores`.
57+
58+
First we need to calculate the deltas for each field of _x_.
59+
60+
_T<sub>delta</sub>_ = _x.total<sub>i</sub>_ - _x.total<sub>i-1</sub>_
61+
62+
_R<sub>delta</sub>_ = _x.readLock<sub>i</sub>_ - _x.readLock<sub>i-1</sub>_
63+
64+
_W<sub>delta</sub>_ = _x.writeLock<sub>i</sub>_ - _x.writeLock<sub>i-1</sub>_
65+
66+
**We can calculate the system load as follows:**
67+
68+
_SYSTEM LOAD_ = (_T<sub>delta</sub>_ * 100) / (_P_* _N_)
69+
70+
## Slow Operations
71+
72+
The `current-op-store` listens to the `pollCurrentOp`, `pause`, and `restart` actions. When `pollCurrentOp` is triggered, it calls [the currentOp command](https://docs.mongodb.com/manual/reference/method/db.currentOp) on the DataService and passes the list of active slowest operations to the `current-op-component`.
73+
74+
The `restart` action clears the stored data in each of the chart stores and the `pause` action stops new data from being displayed but continues to collect data.
75+
76+
## DB Errors
77+
78+
If any of `server-stats-graphs-store`, `top-store`, or `current-op-store` receive an error from the DataService, they will trigger the `dbError` action. The `dberror-store` listens for errors and passes any new errors to the `dberror-component` which will display a red banner with an interpretation of the error received. The raw errors are transformed from MongoErrors to more human-readable and helpful error messages with [mongodb-js-errors.translate](https://github.com/mongodb-js/errors/blob/master/index.js). If an error goes away, i.e. dbError is triggered and the error is now null, then the banner will be removed. If the d3 charts receive data with a non-null error they will not draw the charts and instead display "DATA UNAVAILABLE".
879

9-
#### Definitions
1080

1181
| Key | Description |
1282
|--------------------|----------------------------------------------|

0 commit comments

Comments
 (0)