Skip to main content

Streaming Batch Protocol(SBP) v0.1

Overview

The Streaming Batch Protocol (SBP) is a frame base protocol. All frames begin with a fixed 12-octet header, followed by an extended header and payload. Below graph shows the layout of a frame.

Frame Layout

The protocol is big-endian (network byte order).

Each frame consists of a fixed-size header, followed by a variable-size extended header and payload. Section 2 describes the header, while the content of the extended header and payload depends on the operation code specified in the header. Section 4 provides details about supported operation codes and their corresponding payloads. The SBP frame format considers the payload as opaque, which means that it is interpreted by the application layer.

The design of SBP follows two principles:

  • Batch: SBP is designed to support batch processing to reduce network communication overhead. This allows clients to send multiple requests in one frame or vice versa.
  • Streaming: The server has the capability to respond to requests in a streaming manner, as opposed to responding to all requests at once, which can decrease response latency significantly.

Frame Header

The Frame Header is a fixed 12-octet header that appears at the beginning of every frame. It contains fields for the Frame Length, Magic Code, Operation Code, Flags, and Stream Identifier.

Frame Length

The length of the frame is expressed as a 32-bit integer. Frame Length = 16 + Header.length + Payload.length.

Magic Code

A fixed value representing the protocol self. Currently, the value is 23. This field is used to detect the presence of the SBP protocol, and implementations MUST discard any frame that does not contain the correct magic number.

Operation Code

The 16-bit opcode of the frame. The frame opcode determines the format and semantics of the frame. Implementations MUST ignore and discard any frame with an unknown opcode.

Flags

Flags apply to this frame. The flags have the following meaning (described by the mask that allows selecting them):

  • 0x01: Response flag. If set, the frame contains the response payload to a specific request frame identified by a stream identifier. If not set, the frame represents a request frame.
  • 0x02: Response end flag. If set, the frame is the last frame in a response sequence. If not set, the response sequence continues with more frames. The response sequence may contain one or more frames.
  • 0x04: System error flag. If a response frame has the this flag set, its extended header will be type of SystemErrorResponse.

The rest of the flags are currently unused and ignored.

Stream Identifier

A unique identifier for a request frame or a stream request frame. That is, it is used to support request-response or streaming communication models simultaneously. The stream identifier is expressed as a 32-bit integer in network byte order.

When communicating with the server, the client must set this stream id to a non-negative value. It is ensured that the request and response frames will have matching stream ids.

Extended Header

The extended header starts with format and length fields. The format field is used to identify the serialization format of the extended header. The length field is used to determine the length of the extended header. The length field is expressed as a 24-bit integer in network byte order. The extended header is followed by the payload.

Currently, SBP only defines one format type:

  • 0x01: FlatBuffers format indicates that the payload of the extended header is serialized by flatbuffers.

Frame Definitions

This specification outlines various types of frames, each with a unique 16-bit opcode to identify them. Each frame type has its own specific extended header and payload.

The table below shows all the supported frame types along with a preallocated opcode.

OpcodeFrame TypeDescription
0x0001PINGMeasure a minimal round-trip time from the sender.
0x0002GOAWAYInitiate a shutdown of a connection or signal serious error conditions.
0x0003HEARTBEATTo keep clients alive through periodic heartbeat frames.
0x0004ALLOCATE_IDAllocate a unique identifier from placement drivers.
0x1001APPENDAppend records to the range server.
0x1002FETCHFetch records from the range server.
0x2001LIST_RANGESList ranges from the PD of a batch of streams.
0x2002SEAL_RANGERequest to seal a range of a stream. Both PD and range-server serve this operation accordingly
0x2003SYNC_RANGESSyncs newly writable ranges to a range server to accelerate the availability of a newly created writable range.
0x2004CRATE_RANGERequest PD to create a new range for the specified stream
0x2005DESCRIBE_RANGEDescribe the details of a batch of ranges, mainly used to get the max offset of the current writable range.
0x3001CREATE_STREAMSCreate a batch of streams.
0x3002DELETE_STREAMSDelete a batch of streams.
0x3003UPDATE_STREAMSUpdate a batch of streams.
0x3004DESCRIBE_STREAMSFetch the details of a batch of streams.
0x3005TRIM_STREAMSTrim the min offset of a batch of streams.
0x4001REPORT_METRICSRange Server reports metrics to the PD.
0x4002DESCRIBE_PD_CLUSTERDescribe placement driver cluster membership

The below sub-sections describe the details of each frame type, including their usage, their binary format, and the meaning of their fields.

PING

The PING frame (opcode=0x0001) is a mechanism for measuring a minimal round-trip time from the sender, as well as determining whether an idle connection is still functional. PING frames can be sent from any endpoint.

Receivers of a PING frame set the response flag and the response end flag to do a PONG, with the same extended headers and payload.

GOAWAY

The GOAWAY frame (opcode=0x0002) is used to initiate the shutdown of a connection or to signal serious error conditions. GOAWAY allows an endpoint to gracefully stop accepting new streams while still finishing the processing of previously established streams. This enables administrative actions, like server maintenance.

HEARTBEAT

The HEARTBEAT frame(opcode=0x0003) is used to keep clients alive, carrying the necessary role and status information.

The client can send a heartbeat frame to the server periodically. If the server does not receive any heartbeat frame from the client for a long time, the server may close the connection, even clean up the resources of the client.

Request Frame:

Request Header => client_id client_role range_server
client_id => string
client_role => enum {RANGE_SERVER, CLIENT}
range_server => server_id advertise_addr
server_id => int32
advertise_addr => string

Request Payload => Empty

Response Frame:

Response Header => client_id client_role range_server
client_id => string
client_role => enum {RANGE_SERVER, CLIENT}
range_server => server_id advertise_addr
server_id => int32
advertise_addr => string
status => code message detail
code => int16
message => string
detail => bytes

Response Payload => Empty

The request and response frames of HEARTBEAT have the same format. The table below shows the meaning of each field.

FieldTypeDescription
client_idstringThe unique id of the client.
client_roleenumThe role of the client. Note the client is a relative term, it can be a range server or a SDK client.
range_serverstructOptional, the server information of the range server. Empty if the client is a SDK client.
server_idint32The unique id of the server.
advertise_addrstringThe advertise address of the server, for client traffic from outside. The scheme is host:port, while host supports both domain name and IPv4/IPv6 address.
statusstructThe error status of the response.
codeint16The error code of the response.
messagestringThe error message of the response.
detailbytesAdditional information about the error.

ALLOCATE_ID

The ALLOCATE_ID frame(opcode=0x0004) allocates a unique identifier from placement drivers.

Request Frame:

Request Header => timeout_ms, host

Request Payload => Empty
FieldTypeDescription
timeout_msint32Request would be valid within the duration in milliseconds
hostStringHost name of the applicant

Response Frame:

Response Header => id
status => code message detail
code => int16
message => string
detail => bytes

Response Payload => Empty

APPEND

The APPEND frame(opcode=0x1001) appends record batches to the range server.

Request Frame:

Request Header => timeout_ms [append_request]
timeout_ms => int32
append_requests => stream_id request_index batch_length
stream_id => int64
request_index => int32
batch_length => int32

Request Payload => [stream_data]
stream_data => record_batch
record_batch => bytes
FieldTypeDescription
timeout_msint32The timeout to await a response in milliseconds.
append_requestsarrayA batch of append requests.
stream_idint64The id of the stream.
request_indexint32The index number of an append request in the batch requests. The response to each request may be out of order, even in different response frames.
batch_lengthint32The payload length of this record batch.
stream_dataarrayThe array of record batches.
record_batchbytesThe payload of each record batch, already serialized by clients.

Response Frame:

Response Header => throttle_time_ms [append_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
append_responses => stream_id request_index base_offset stream_append_time_ms status
stream_id => int64
request_index => int32
base_offset => int64
stream_append_time_ms => int64
status => code message detail
code => int16
message => string
detail => bytes

Response Payload => Empty
FieldTypeDescription
throttle_time_msint32The time in milliseconds to throttle the client, due to a quota violation or the server is too busy.
statusstructThe error status of the response.
codeint16The top level error code of the response.
messagestringThe top level error message of the response.
detailbytesAdditional information about the error.
append_responsesarrayA batch of append responses.
stream_idint64The target stream_id of the append record batch.
request_indexint32The request_index that the append_response relates to.
base_offsetint64The base offset of the record batch.
stream_append_time_msint64The timestamp returned by the range server server after appending the records.
statusstructThe error status of a fetch response.
codeint16The error code, or 0 if there was no error.
messagestringThe error message, or null if there was no error.
detailbytesAdditional information about the error.

FETCH

The FETCH frame(opcode=0x1002) fetches record batches from the range server. This frame supports fetching data from multiple streams in one frame, and the response could be split into multiple frames then returned in a streaming way. The best benefit of this behavior is that the storage server could return records timely according to the arrival of the records, which is very useful for real-time data processing.

Request Frame:

Request Header => max_wait_ms min_bytes [fetch_requests]
max_wait_ms => int32
min_bytes => int32
fetch_requests => stream_id fetch_offset batch_max_bytes
stream_id => int64
request_index => int32
fetch_offset => int64
batch_max_bytes => int32

Request Payload => Empty
FieldTypeDescription
max_wait_msint32The maximum time in milliseconds to wait for the response.
min_bytesint32The maximum time in milliseconds to wait for the response.
fetch_requestsarrayA batch of fetch requests to fetch data from different streams.
stream_idint64A specific stream to fetch data.
request_indexint32The index number of a fetch request in the batch requests. The response to each request may be out of order, even in different response frames.
fetch_offsetint64The start offset to fetch data in a specific stream.
batch_max_bytesint32The maximum bytes of the current batch to fetch from the stream.

Response Frame:

Response Header => throttle_time_ms [fetch_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
fetch_responses => stream_id request_index batch_length status
stream_id => int64
request_index => int32
batch_length => int32
status => code message detail
code => int16
message => string
detail => bytes

Response Payload => [stream_data]
stream_data => record_batch
record_batch => bytes
FieldTypeDescription
throttle_time_msint32The time in milliseconds to throttle the client, due to a quota violation or the server is too busy.
statusstructThe error status of the response.
codeint16The top level error code of the response.
messagestringThe top level error message of the response.
detailbytesAdditional information about the error.
fetch_responsesarrayA batch of fetch responses.
stream_idint64The id of the stream that the data is fetched from.
request_indexint8The request_index that the fetch_response relates to.
batch_lengthint32The data length of the returned batch is used to decode the data from the payload.
statusstructThe error status of a fetch response.
codeint16The error code, or 0 if there was no error.
messagestringThe error message, or null if there was no error.
detailbytesAdditional information about the error.
stream_dataarrayThe array of record batches, fetched from multiple stream ranges.
record_batchbytesThe payload of each record batch, already serialized.

LIST_RANGES

The LIST_RANGES frame(opcode=0x2001) lists the ranges of a batch of streams. Or it could list the ranges of all the streams in a specific range server.

Request Frame:

There are two types of LIST_RANGES request, one is to list the ranges of a batch of streams, and the other is to list the ranges of all the streams in a specific range server.

Request Header => timeout_ms [range_owners]
timeout_ms => int32
range_owners => union { stream_id, range_server }
// List the ranges of streams
stream_id => int64
// List the ranges of a specific range server
range_server => server_id advertise_addr
server_id => int32
advertise_addr => string

Request Payload => Empty
FieldTypeDescription
timeout_msint32The timeout in milliseconds to wait for the response.
range_ownersunionThe array of owner of the ranges to list.
stream_idint64A specific stream to list the ranges.
range_serverstructA specific range server to list the ranges of all the streams.
server_idint32The server id of the range server.
advertise_addrstringThe advertise address of the range server.

Response Frame:

Response Header => throttle_time_ms [list_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
list_responses => stream_id status [ranges]
stream_id => int64
status => code message detail
code => int16
message => string
detail => bytes
ranges => stream_id range_index start_offset next_offset end_offset [servers]
stream_id => int64
range_index => int32
start_offset => int64
next_offset => int64
end_offset => int64
servers => server is_primary
server => server_id advertise_addr
server_id => int32
advertise_addr => string
is_primary => bool

Response Payload => Empty
FieldTypeDescription
throttle_time_msint32The time in milliseconds to throttle the client, due to a quota violation or the server is too busy.
statusstructThe error status of the response.
codeint16The top level error code of the response.
messagestringThe top level error message of the response.
detailbytesAdditional information about the error.
list_responsesarrayA batch of list range responses.
stream_idint64The target stream_id of the list ranges response.
statusstructThe error status of a fetch response.
codeint16The error code, or 0 if there was no error.
messagestringThe error message, or null if there was no error.
detailbytesAdditional information about the error.
rangesarrayThe array of ranges, belonging to a specific stream.
range_indexint32The index of the range in the stream.
start_offsetint64The start offset of the range.
next_offsetint64The next writable offset for incoming records of the range. It's a snapshot of the next offset of the range, and it may be changed after the response is sent.
end_offsetint64Optional. The end offset of the range. Empty if the range is open.
serversarrayThe array of servers that host the range, containing the range server information of the range.
range_serverstructThe range server information of the range.
server_idint32The server id of the range server.
advertise_addrstringThe advertise address of the range server.
is_primaryboolWhether the range in current range server is primary or secondary.

SEAL_RANGES

The SEAL_RANGES frame(opcode=0x2002) seals the current writable ranges of a batch of streams.

Request Frame:

Request Header => timeout_ms [ranges]
timeout_ms => int32
ranges => stream_id range_index
stream_id => int64
range_index => int32

Request Payload => Empty
FieldTypeDescription
timeout_msint32The timeout in milliseconds to wait for the response.
rangesarrayA batch of ranges to seal.
stream_idint64A specific stream that the range belongs to.
range_indexint32A specific range to seal in the stream.

Response Frame:

Response Header => throttle_time_ms [seal_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
seal_responses => stream_id status [ranges]
stream_id => int64
status => code message detail
code => int16
message => string
detail => bytes
range => ...

Response Payload => Empty
FieldTypeDescription
throttle_time_msint32The time in milliseconds to throttle the client, due to a quota violation or the server is too busy.
statusstructThe error status of the response.
codeint16The top level error code of the response.
messagestringThe top level error message of the response.
detailbytesAdditional information about the error.
seal_responsesarrayA batch of stream responses.
stream_idint64The target stream_id of the seal ranges response.
statusstructThe error status of a fetch response.
codeint16The error code, or 0 if there was no error.
messagestringThe error message, or null if there was no error.
detailbytesAdditional information about the error.
rangestructBoth the PD and the range server will handle the seal ranges request. The range server returns the sealed range, while the PD returns the newly writable range.

SYNC_RANGES

The SYNC_RANGES frame(opcode=0x2003) syncs newly writable ranges to accelerate the availability of a newly created writable range.

Or, it could be used to assign a new replics of a range to a new range server.

Request Frame:

Request Header => timeout_ms [stream_ranges]
timeout_ms => int32
stream_ranges => stream_id [ranges]
stream_id => int64
ranges => ...

Request Payload => Empty
FieldTypeDescription
timeout_msint32The timeout in milliseconds to wait for the response.
stream_rangesarrayA batch of stream ids to sync the ranges.
stream_idint64A specific stream to sync the ranges.
rangesarrayA specific range to sync to the range server.

Response Frame:

Response Header => throttle_time_ms [sync_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
sync_responses => stream_id status range
stream_id => int64
status => code message detail
code => int16
message => string
detail => bytes
ranges => ...

Response Payload => Empty

The response frame is similar to the request frame, so the detailed description is omitted.

DESCRIBE_RANGES

The DESCRIBE_RANGES frame(opcode=0x2004) describes the ranges of a batch of streams. Usually, the client will use this frame to get the newly end offset of the stream after the write operation.

Request Frame:

Request Header => timeout_ms [ranges]
timeout_ms => int32
ranges => stream_id range_index
stream_id => int64
range_index => int32
FieldTypeDescription
timeout_msint32The timeout in milliseconds to wait for the response.
rangesarrayA range array to describe.
stream_idint64A specific stream to describe the ranges.
range_indexint32A specific range to describe.

Response Frame:

Response Header => throttle_time_ms [describe_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
describe_responses => stream_id status range
stream_id => int64
status => code message detail
code => int16
message => string
detail => bytes
range => ...
FieldTypeDescription
throttle_time_msint32The time in milliseconds to throttle the client, due to a quota violation or the server is too busy.
statusstructThe error status of the response.
codeint16The top level error code of the response.
messagestringThe top level error message of the response.
detailbytesAdditional information about the error.
describe_responsesarrayA batch of describe responses.
stream_idint64The target stream_id of the describe ranges response.
statusstructThe error status of a fetch response.
codeint16The error code, or 0 if there was no error.
messagestringThe error message, or null if there was no error.
detailbytesAdditional information about the error.
rangestructThe range, returned by the describe ranges request.

CREATE_STREAMS

The CREATE_STREAMS frame(opcode=0x3001) creates a batch of streams to PD. This frame with batch ability is very useful for importing metadata from other systems.

Request Frame:

Request Header => timeout_ms [streams]
timeout_ms
streams => replica_nums retention_period_ms
replica_nums => int8
retention_period_ms => int64

Request Payload => Empty
FieldTypeDescription
timeout_msint32The timeout in milliseconds to wait for the response.
streamsarrayA batch of streams to create.
replica_numsint8The number of replicas of the stream.
retention_period_msint64The retention period of the records in the stream in milliseconds.

Response Frame:

Response Header => throttle_time_ms [create_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
create_responses => stream replica_nums retention_period_ms status
stream => stream_id replica_nums retention_period_ms
stream_id => int64
replica_nums => int8
retention_period_ms => int64
status => code message detail
code => int16
message => string
detail => bytes

Response Payload => Empty
FieldTypeDescription
throttle_time_msint32The time in milliseconds to throttle the client, due to a quota violation or the server is too busy.
statusstructThe error status of the response.
codeint16The top level error code of the response.
messagestringThe top level error message of the response.
detailbytesAdditional information about the error.
create_responsesarrayA batch of create stream responses.
streamstructThe struct of createed stream, returned by the create streams request.
stream_idint64The stream_id of the create streams response.
replica_numsint8The number of replicas of the stream.
retention_period_msint64The retention period of the records in the stream in milliseconds.
statusstructThe error status of a fetch response.
codeint16The error code, or 0 if there was no error.
messagestringThe error message, or null if there was no error.
detailbytesAdditional information about the error.

DELETE_STREAMS

The DELETE_STREAMS frame(opcode=0x3002) deletes a batch of streams to PD or range server. The PD will delete the stream metadata as well as the range info, while the range server only marks the stream as deleted to reject the new write requests timely.

Request Frame:

Request Header => timeout_ms [streams]
timeout_ms
streams => stream_id replica_nums retention_period_ms
stream_id => int64
replica_nums => int8
retention_period_ms => int64

Request Payload => Empty

Only the stream_id is required in the request frame, the other fields are ignored.

The frame is simple, so the detailed description is omitted.

Response Frame:

Response Header => throttle_time_ms [delete_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
responses => deleted_stream status
deleted_stream => stream_id replica_nums retention_period_ms
stream_id => int64
replica_nums => int8
retention_period_ms => int64
status => code message detail
code => int16
message => string
detail => bytes

Request Payload => Empty

The deleted_stream will be returned if the stream is deleted successfully, otherwise the code and message in error status will be returned.

The frame is simple, so the detailed description is omitted.

UPDATE_STREAMS

The UPDATE_STREAMS frame(opcode=0x3003) updates a batch of streams to PD. The frame is similar to the CREATE_STREAMS frame

Request Frame:

Request Header => timeout_ms [streams]
timeout_ms
streams => stream_id replica_nums retention_period_ms
stream_id => int64
replica_nums => int8
retention_period_ms => int64

Request Payload => Empty

Response Frame:

Response Header => throttle_time_ms [update_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
update_responses => updated_stream status
updated_stream => stream_id replica_nums retention_period_ms
stream_id => int64
replica_nums => int8
retention_period_ms => int64
status => code message detail
code => int16
message => string
detail => bytes

Response Payload => Empty

These two frames are similar with the CREATE_STREAMS frame, so the detailed description is omitted.

DESCRIBE_STREAMS

The DESCRIBE_STREAMS frame(opcode=0x3004) describes a batch of streams from PD. The response frame is similar to the CREATE_STREAMS frame.

Request Frame:

Request Header => timeout_ms [stream_ids]
timeout_ms
stream_ids => stream_id
stream_id => int64

Request Payload => Empty

Response Frame:

Response Header => throttle_time_ms [describe_responses]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
describe_responses => stream status
stream => stream_id replica_nums retention_period_ms
stream_id => int64
replica_nums => int8
retention_period_ms => int64
status => code message detail
code => int16
message => string
detail => bytes

Response Payload => Empty

TRIM_STREAMS

The TRIM_STREAMS frame(opcode=0x3005) trims a batch of streams to PD.

The range server stores the records in the stream in a log structure, and the records are appended to the end of the log. Consider the length of disk is limited, the range server will delete the records to recycling the disk space. Once the deletion occurs, some ranges should be trimmed to avoid the clients to read the deleted records.

The range server will send the TRIM_STREAMS frame to the PD to trim the stream with a trim offset. The PD will delete the ranges whose end offset is less than the trim offset and shrink the ranges whose start offset is less than the trim offset.

Request Frame:

Request Header => timeout_ms [trimmed_streams]
timeout_ms
trimmed_streams => stream_id trim_offset
stream_id => int64
trim_offset => int64
FieldTypeDescription
timeout_msint32The timeout in milliseconds to wait for the response.
trimmed_streamsarrayA batch of streams to trim.
stream_idint64The stream_id of the stream to trim.
trim_offsetint64The trim offset of the stream.

Response Frame:

Response Header => throttle_time_ms [streams]
throttle_time_ms => int32
status => code message detail
code => int16
message => string
detail => bytes
streams => trimmed_stream status range
trimmed_stream => stream_id replica_nums retention_period_ms
stream_id => int64
replica_nums => int8
retention_period_ms => int64
status => code message detail
code => int16
message => string
detail => bytes
range => ...
FieldTypeDescription
throttle_time_msint32The time in milliseconds to throttle the client, due to a quota violation or the server is too busy.
statusstructThe error status of the response.
codeint16The top level error code of the response.
messagestringThe top level error message of the response.
detailbytesAdditional information about the error.
streamsarrayA batch of stream responses.
stream_idint64The stream_id of the trim streams response.
statusstructThe error status of a fetch response.
codeint16The error code, or 0 if there was no error.
messagestringThe error message, or null if there was no error.
detailbytesAdditional information about the error.
rangestructThe smallest range of the stream after a trim operation.

REPORT_METRICS

The REPORT_METRICS frame(opcode=0x4001) reports load metrics of Range Server to PD. PD uses these metrics to allocate ranges.

Request Frame:

Request Header => range_server
range_server => server_id advertise_addr
server_id => int32
advertise_addr => string
disk_in_rate => int64
disk_out_rate => int64
disk_free_space => int64
disk_unindexed_data_size => int64
memory_used => int64
uring_task_rate => int16
uring_inflight_task_cnt => int16
uring_pending_task_cnt => int32
uring_task_avg_latency => int16
network_append_rate => int16
network_fetch_rate => int16
network_failed_append_rate => int16
network_failed_fetch_rate => int16
network_append_avg_latency => int16
network_fetch_avg_latency => int16
range_missing_replica_cnt => int16
range_active_cnt => int16

Request Payload => Empty
FieldTypeDescription
hostnamestringRange Server's hostname.
disk_in_rateint64Number of bytes written to the disk per second.
disk_out_rateint64Number of bytes read from the disk per second.
disk_free_spaceint64Disk free space size, measured in bytes.
disk_unindexed_data_sizeint64Size of the data that has not yet been indexed, measured in bytes.
memory_usedint64Used memory size, measured in bytes.
uring_task_rateint16Number of tasks completed per second in uring.
uring_inflight_task_cntint16Number of inflight tasks in uring.
uring_pending_task_cntint32Number of pending tasks in uring.
uring_task_avg_latencyint16Average latency of completed tasks over the past minute in uring, measured in ms.
network_append_rateint16Number of append requests per second.
network_fetch_rateint16Number of fetch requests per second.
network_failed_append_rateint16Number of failed append requests per second.
network_failed_fetch_rateint16Number of failed fetch requests per second.
network_append_avg_latencyint16Average latency of append requests over the past minute, measured in ms.
network_fetch_avg_latencyint16Average latency of fetch requests over the past minute, measured in ms.
range_missing_replica_cntint16Number of replicas that need to be copied from other Range Server.
range_active_cntint16Number of active(recently read or write) ranges in the past minute.

Response Frame:

Response Header => range_server
range_server => server_id advertise_addr
server_id => int32
advertise_addr => string
status => code message detail
code => int16
message => string
detail => bytes

Response Payload => Empty

DESCRIBE_PD_CLUSTER

The DESCRIBE_PD_CLUSTER frame(opcode=0x4002) requests placement driver to describe its current cluster membership. Embedded clients of the range-server MUST send heartbeats / load metrics to all PD nodes.

Request Frame

Request Header => range_server
range_server => server_id advertise_addr
server_id => int32
advertise_addr => string
timeout_ms

Request Payload => Empty
FieldTypeDescription
timeout_msint32The timeout in milliseconds to wait for the response.
server_idint32The request range-server ID
advertise_addrstringadvertise address of the range-server

Response Frame:

Response Header=> status
status =>
code => int16
message => string
detail => bytes
cluster => PlacementDriverCluster

Response Body => Empty
FieldTypeDescription
throttle_time_msint32The time in milliseconds to throttle the client, due to a quota violation or the server is too busy.
statusstructThe error status of the response.
codeint16The top level error code of the response.
messagestringThe top level error message of the response.
detailbytesAdditional information about the error.

Error Codes

The SBP protocol defines a set of numeric error codes that are used to indicate the type of occurred error. These error codes are used in the status.code field of the response header, and can be translated by the client to a human-readable error message.

System Error Frame

There is a special error frame that is used to indicate that the server encountered an unexpected error or a request-agnostic error. The error frame is sent with the following format:

Error Response Header => status
status => code message detail
code => int16
message => string
detail => bytes

When the system error flag is set, the above error frame is sent instead of the normal response frame.

Error Codes Table

The error codes are defined in the following table.

ERRORCODERETRIABLEDESCRIPTION
NONE0NoNo error
UNKNOWN1NoAn unexpected server error
INVALID_REQUEST2NoThe request is invalid
UNSUPPORTED_VERSION3NoThe version of the request is not supported
PD_NOT_LEADER5NoThe requested PD node is not the leader.

References

  1. HTTP2: https://httpwg.org/specs/rfc7540.html
  2. FlatBuffers: https://google.github.io/flatbuffers/
  3. CQL BINARY PROTOCOL v4: https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v4.spec
  4. Kafka Protocol: https://kafka.apache.org/protocol.html#protocol_versioning