Skip to content

Commit

Permalink
kvserver: add replica load info for hotranges
Browse files Browse the repository at this point in the history
Previously, HotRanges would report the replica descriptor and queries
per second (QPS) of the hottest ranges per store; ranked by QPS. This
patch introduces the additional range load information: requests per
second `RequestsPerSecond`, writes per second `WriteKeysPerSecond`, reads per second `ReadsPerSecond`, write
bytes per second `WriteBytesPerSecond` and read bytes per second `ReadBytesPerSecond`. These
additional load metrics are useful for hot range inspection, as they
provide a more granular view of range load, than QPS alone.

Release note (ops change): HottestRanges will now report additional range
statistics for the reported ranges. These statistics are:
requests per second, the number of requests received by this range
recently per second; writes per second, the number of keys written to in
this range recently per second; reads per second, the number of keys
read from this range recently, per second; write bytes per second, the
number of bytes written to this range recently, per second; and the read
bytes per second, the number of bytes read from this range recently, per
second.
  • Loading branch information
kvoli committed Apr 14, 2022
1 parent 3b8dfac commit 790c95a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/generated/http/full.md
Original file line number Diff line number Diff line change
Expand Up @@ -3459,6 +3459,11 @@ target node(s) selected in a HotRangesRequest.
| desc | [cockroach.roachpb.RangeDescriptor](#cockroach.server.serverpb.HotRangesResponse-cockroach.roachpb.RangeDescriptor) | | Desc is the descriptor of the range for which the report was produced.<br><br>TODO(knz): This field should be removed. See: https://github.com/cockroachdb/cockroach/issues/53212 | [reserved](#support-status) |
| queries_per_second | [double](#cockroach.server.serverpb.HotRangesResponse-double) | | QueriesPerSecond is the recent number of queries per second on this range. | [alpha](#support-status) |
| leaseholder_node_id | [int32](#cockroach.server.serverpb.HotRangesResponse-int32) | | LeaseholderNodeID indicates the Node ID that is the current leaseholder for the given range. | [reserved](#support-status) |
| requests_per_second | [double](#cockroach.server.serverpb.HotRangesResponse-double) | | Requests per second is the recent number of requests received per second on this range. | [reserved](#support-status) |
| writes_per_second | [double](#cockroach.server.serverpb.HotRangesResponse-double) | | Writes per second is the recent number of keys written per second on this range. | [reserved](#support-status) |
| reads_per_second | [double](#cockroach.server.serverpb.HotRangesResponse-double) | | Reads per second is the recent number of keys read per second on this range. | [reserved](#support-status) |
| write_bytes_per_second | [double](#cockroach.server.serverpb.HotRangesResponse-double) | | Write bytes per second is the recent number of bytes written per second on this range. | [reserved](#support-status) |
| read_bytes_per_second | [double](#cockroach.server.serverpb.HotRangesResponse-double) | | Read bytes per second is the recent number of bytes read per second on this range. | [reserved](#support-status) |



Expand Down
5 changes: 5 additions & 0 deletions docs/generated/http/hotranges-other.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,10 @@ Support status: [alpha](#support-status)
| desc | [cockroach.roachpb.RangeDescriptor](#cockroach.roachpb.RangeDescriptor) | | Desc is the descriptor of the range for which the report was produced.<br><br>TODO(knz): This field should be removed. See: https://github.com/cockroachdb/cockroach/issues/53212 | [reserved](#support-status) |
| queries_per_second | [double](#double) | | QueriesPerSecond is the recent number of queries per second on this range. | [alpha](#support-status) |
| leaseholder_node_id | [int32](#int32) | | LeaseholderNodeID indicates the Node ID that is the current leaseholder for the given range. | [reserved](#support-status) |
| requests_per_second | [double](#double) | | Requests per second is the recent number of requests received per second on this range. | [reserved](#support-status) |
| writes_per_second | [double](#double) | | Writes per second is the recent number of keys written per second on this range. | [reserved](#support-status) |
| reads_per_second | [double](#double) | | Reads per second is the recent number of keys read per second on this range. | [reserved](#support-status) |
| write_bytes_per_second | [double](#double) | | Write bytes per second is the recent number of bytes written per second on this range. | [reserved](#support-status) |
| read_bytes_per_second | [double](#double) | | Read bytes per second is the recent number of bytes read per second on this range. | [reserved](#support-status) |


14 changes: 12 additions & 2 deletions pkg/kv/kvserver/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3287,8 +3287,13 @@ func (s *Store) ClusterNodeCount() int {

// HotReplicaInfo contains a range descriptor and its QPS.
type HotReplicaInfo struct {
Desc *roachpb.RangeDescriptor
QPS float64
Desc *roachpb.RangeDescriptor
QPS float64
RequestsPerSecond float64
ReadKeysPerSecond float64
WriteKeysPerSecond float64
WriteBytesPerSecond float64
ReadBytesPerSecond float64
}

// HottestReplicas returns the hottest replicas on a store, sorted by their
Expand All @@ -3302,6 +3307,11 @@ func (s *Store) HottestReplicas() []HotReplicaInfo {
for i := range topQPS {
hotRepls[i].Desc = topQPS[i].repl.Desc()
hotRepls[i].QPS = topQPS[i].qps
hotRepls[i].RequestsPerSecond = topQPS[i].repl.RequestsPerSecond()
hotRepls[i].WriteKeysPerSecond = topQPS[i].repl.WritesPerSecond()
hotRepls[i].ReadKeysPerSecond = topQPS[i].repl.ReadsPerSecond()
hotRepls[i].WriteBytesPerSecond = topQPS[i].repl.WriteBytesPerSecond()
hotRepls[i].ReadBytesPerSecond = topQPS[i].repl.ReadBytesPerSecond()
}
return hotRepls
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/server/serverpb/status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,22 @@ message HotRangesResponse {
(gogoproto.casttype) =
"github.com/cockroachdb/cockroach/pkg/roachpb.NodeID"
];

// Requests per second is the recent number of requests received per
// second on this range.
double requests_per_second = 4;
// Writes per second is the recent number of keys written per second on
// this range.
double writes_per_second = 5;
// Reads per second is the recent number of keys read per second on
// this range.
double reads_per_second = 6;
// Write bytes per second is the recent number of bytes written per second on
// this range.
double write_bytes_per_second = 7;
// Read bytes per second is the recent number of bytes read per second on
// this range.
double read_bytes_per_second = 8;
}

// StoreResponse contains the part of a hot ranges report that
Expand Down
5 changes: 5 additions & 0 deletions pkg/server/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,11 @@ func (s *statusServer) localHotRanges(ctx context.Context) serverpb.HotRangesRes
}
storeResp.HotRanges[i].Desc = *r.Desc
storeResp.HotRanges[i].QueriesPerSecond = r.QPS
storeResp.HotRanges[i].RequestsPerSecond = r.RequestsPerSecond
storeResp.HotRanges[i].WritesPerSecond = r.WriteKeysPerSecond
storeResp.HotRanges[i].ReadsPerSecond = r.ReadKeysPerSecond
storeResp.HotRanges[i].WriteBytesPerSecond = r.WriteBytesPerSecond
storeResp.HotRanges[i].ReadBytesPerSecond = r.ReadBytesPerSecond
}
resp.Stores = append(resp.Stores, storeResp)
return nil
Expand Down

0 comments on commit 790c95a

Please sign in to comment.