Throttr — Sovereign Real-Time Data & Messaging EngineThrottr — Sovereign Real-Time Data & Messaging Engine
Home
Get Started
About Protocol
About Server
Home
Get Started
About Protocol
About Server
  • About Protocol

About Protocol

Introduction

The Throttr Server, including the SDK's, implements a binary protocol on their codes. The protocol defines all the request types and responses in order to make transactions efficient and well-known.

All the source code is available under the official GitHub repository

Definitions

If you want to understand the logic behind the scene, and you're developer or architect, then, this documentation is great for you because it explains byte per byte how Throttr message protocol works.

To start that process, I consider absolutely necessary talk about some concepts first.

Time to Live (TTL)

Is a period of time computed from the now() function of the server plus the amount units on the respective time system used. During that period, the resource attached to the TTL can be considered as valid.

In example; a TTL of 60 seconds will be marked as expired and removed by the scheduler after a minute.

TTL Types

Is the time unit system used to measure the TTL on the record.

The implemented types are:

NameBinary
Nanoseconds0x01
Microseconds0x02
Milliseconds0x03
Seconds0x04
Minutes0x05
Hours0x06

Record

Is an in-memory system entity, identify by a key. It can be a counter or buffer.

Records are designed to expire in some time point. That point is established when the record is created and modified during TTL's updates.

Key

Is a unique value to identify the record in the system. His value is stored in a binary container and comparable using hashing. You can define the keys that fit with your use cases.

Maximum Values

The protocol defines a numeric limit to all operations and it must be selected to fit with the use case.

To understand this dimension, consider Quota as X, TTL as Y and Buffer as Z.

Then:

  • To length of Z and value of X and Y:
    • Lower than 255 then use uint8.
    • Lower than 65.535 then use uint16.
    • Lower than 4.294.967.295 then use uint32.
    • Lower than 2^64 - 1 then use uint64.

Why is so important?

Because if you choose the optimal variant, you'll reduce the RAM and Bandwidth used by the server and clients. If your cases can be solved by uint8 then, using uint64, you'll be wasting 7 bytes per dynamic field.

Dynamic Value Size

The dynamic size (N) is the variable quantity of bytes who are used on dynamic fields, previously described to store and transmit data. So:

VariantLength
uint81 byte
uint162 bytes
uint324 bytes
uint648 bytes

Endianness

The endianness is the way how multibyte data is stored in memory.

Big Endian stores the most significant byte first, meaning the highest-order byte comes at the lowest memory address.

Little Endian, on the other hand, stores the least significant byte first.

For example, the number 2 represented in two bytes would be stored as:

  • 0x00 0x02 in Big Endian
  • 0x02 0x00 in Little Endian

This order affects how data is interpreted when reading raw bytes in memory or across systems.

Throttr use little endian by default. This reduces the amount of mathematical operations to reorder the data on compatible architecture. Almost all current CPU architecture uses little-endian by default.

Usually, standards of IETF, IEEE and ISO recommend big endian. This protocol doesn't try go against the standard. The protocol tries avoid as possible, the undesired and forced conversion operations, in order to provide less contention.

Request types

Version v7.1.0 supports the following request types:

INSERT

This request can add counters to the memory.

Required fields

Request type

The first byte must be 0x01.

Quota

Is the consumable amount assigned to the key in the time-window. Contained in N bytes.

TTL type

Is the TTL type used by the counter. Contained in 1 byte.

TTL

Is the amount in TTL units applicable to the counter. Contained in N bytes.

Size of key

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Key

Is the key of the record. Contained in M bytes.

Response

The server resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

QUERY

This request can retrieve counters.

Required fields

Request type

The first byte must be 0x02.

Size of key

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Key

Is the key of the record. Contained in M bytes.

Response

The server, usually, resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

If the status was success, then, it also will include:

FieldSize
QUOTAN bytes
TTL TYPE1 byte
TTLN bytes

UPDATE

This request can modify counters and buffers.

Required fields

Request type

The first byte must be 0x03.

Attribute

Is the field to be modified. Contained in 1 byte.

It can be:

AttributeBinary
QUOTA0x00
TTL0x01

The buffers can only be modified using TTL.

Change type

Is the change type to be applied. Contained in 1 byte.

It can be:

ChangeBinary
PATCH0x00
INCREASE0x01
DECREASE0x02

The DECREASE can produce 0x00 as response if the result of the operation over Quota is negative.

Any operation over TTL will invoke the procedure to reschedule the expiration timer.

Value

Is the value to be used. Contained in N bytes.

Size of key

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Key

Is the key of the record. Contained in M bytes.

Response

This server resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

PURGE

This request can remove counters and buffers.

Required fields

Request type

The first byte must be 0x04.

Size of key

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Key

Is the key of the record. Contained in M bytes.

Response

This server resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

SET

This request can add buffers to the memory.

Required fields

Request type

The first byte must be 0x05.

TTL type

Is the TTL type used by the counter. Contained in 1 byte.

TTL

Is the amount in TTL units applicable to the counter. Contained in N bytes.

Size of key

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Size of value

Is the quantity of chars (O) used by the value. Contained in 1 byte.

Key

Is the key of the record. Contained in M bytes.

Value

Is the value of the record. Contained in O bytes.

Response

The server resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

GET

This request can retrieve buffers.

Required fields

Request type

The first byte must be 0x06.

Size of key

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Key

Is the key of the record. Contained in M bytes.

Response

The server, usually, resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

If the status was success, then, it also will include:

FieldSize
TTL TYPE1 byte
TTLN bytes
VALUE SIZE (O)N bytes
VALUEO bytes

LIST

This request can list counters and buffers.

Required fields

Request type

The first byte must be 0x07.

Response

This server resolve this request, initially, by sending 8 bytes response.

FieldSize
FRAGMENTS (P)8 bytes

After that we receive P fragments in 16 bytes:

FieldSize
FRAGMENT8 bytes
NUMBER OF SCOPED KEYS (Q)8 bytes

Per Q we are going to receive fixed 11 + N bytes:

FieldSize
KEY SIZE (QL)1 byte
KEY TYPE1 byte
TTL TYPE1 byte
TIME POINT8 bytes
BYTES USEDN bytes

N represent value_type length.

At the end of the fragment we are going receive the keys in R bytes (sum of QL):

FieldSize
KEYQL bytes

INFO

This request can provide instance related information.

Required fields

Request type

The first byte must be 0x08.

Response

This server resolve this request, initially, by sending 236 bytes response.

FieldSize
TIMESTAMP8 bytes
TOTAL REQUESTS8 bytes
REQUESTS PER MINUTE8 bytes
TOTAL INSERT8 bytes
INSERT PER MINUTE8 bytes
TOTAL QUERY8 bytes
QUERY PER MINUTE8 bytes
TOTAL UPDATE8 bytes
UPDATE PER MINUTE8 bytes
TOTAL PURGE8 bytes
PURGE PER MINUTE8 bytes
TOTAL GET8 bytes
GET PER MINUTE8 bytes
TOTAL SET8 bytes
SET PER MINUTE8 bytes
TOTAL LIST8 bytes
LIST PER MINUTE8 bytes
TOTAL INFO8 bytes
INFO PER MINUTE8 bytes
TOTAL STATS8 bytes
STATS PER MINUTE8 bytes
TOTAL STAT8 bytes
STAT PER MINUTE8 bytes
TOTAL SUBSCRIBE8 bytes
SUBSCRIBE PER MINUTE8 bytes
TOTAL UNSUBSCRIBE8 bytes
UNSUBSCRIBE PER MINUTE8 bytes
TOTAL PUBLISH8 bytes
PUBLISH PER MINUTE8 bytes
TOTAL CHANNEL8 bytes
CHANNEL PER MINUTE8 bytes
TOTAL CHANNELS8 bytes
CHANNELS PER MINUTE8 bytes
TOTAL WHOAMI8 bytes
WHOAMI PER MINUTE8 bytes
TOTAL CONNECTION8 bytes
CONNECTION PER MINUTE8 bytes
TOTAL CONNECTIONS8 bytes
CONNECTIONS PER MINUTE8 bytes
TOTAL READ BYTES8 bytes
READ BYTES PER MINUTE8 bytes
TOTAL WRITE BYTES8 bytes
WRITE BYTES PER MINUTE8 bytes
TOTAL KEYS8 bytes
TOTAL COUNTERS8 bytes
TOTAL BUFFERS8 bytes
TOTAL ALLOCATED BYTES ON COUNTERS8 bytes
TOTAL ALLOCATED BYTES ON BUFFERS8 bytes
TOTAL SUBSCRIPTIONS8 bytes
TOTAL CHANNELS8 bytes
RUNNING SINCE8 bytes
TOTAL CONNECTIONS8 bytes
VERSION16 bytes

STAT

This request can provide metrics for specific counter or buffer.

Required fields

Request type

The first byte must be 0x09.

Size of key

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Key

Is the key of the record. Contained in M bytes.

Response

This server resolve this request by sending 1 byte response.

If the byte is 0x01 then will also include 32 bytes more:

FieldSize
READS PER MINUTE8 bytes
WRITES PER MINUTE8 bytes
TOTAL READS8 bytes
TOTAL WRITES8 bytes

STATS

This request can provide metrics of counters and buffers.

Required fields

Request type

The first byte must be 0x10.

Response

This server resolve this request, initially, by sending 8 bytes response.

FieldSize
FRAGMENTS (P)8 bytes

After that we receive P fragments in 16 bytes:

FieldSize
FRAGMENT8 bytes
NUMBER OF SCOPED KEYS (Q)8 bytes

Per Q we are going to receive fixed 33 bytes:

FieldSize
KEY SIZE (QL)1 byte
READS PER MINUTE8 bytes
WRITES PER MINUTE8 bytes
TOTAL READS8 bytes
TOTAL WRITES8 bytes

N represent value_type length.

At the end of the fragment we are going receive the keys in R bytes (sum of QL):

FieldSize
KEYQL bytes

SUBSCRIBE

This request can start a subscription to a channel.

Required fields

Request type

The first byte must be 0x11.

Size of channel

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Channel

Is the name of the channel. Contained in M bytes.

Response

This server resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

UNSUBSCRIBE

This request can finish a subscription to a channel.

Required fields

Request type

The first byte must be 0x12.

Size of channel

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Channel

Is the name of the channel. Contained in M bytes.

Response

This server resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

PUBLISH

This request can send a buffer to a subscribed channel.

Required fields

Request type

The first byte must be 0x13.

Size of channel

Is the quantity of chars (M) used by the channel. Contained in 1 byte.

Size of payload

Is the quantity of chars (O) used by the payload. Contained in N bytes.

Channel

Is the name of the channel. Contained in M bytes.

Payload

Is the payload. Contained in O bytes.

Response

This server resolve this request by sending 1 byte response.

The client will receive 0x01 on success or 0x00 on failure.

CONNECTIONS

This request can list connections.

Required fields

Request type

The first byte must be 0x14.

Response

This server resolve this request, initially, by sending 8 bytes response.

FieldSize
FRAGMENTS (P)8 bytes

After that we receive P fragments in 16 bytes:

FieldSize
FRAGMENT8 bytes
NUMBER OF SCOPED CONNECTIONS (Q)8 bytes

Per Q we are going to receive fixed 235 bytes:

FieldSize
ID16 bytes
IP VERSION1 byte
IP16 bytes
PORT2 byte
CONNECTED AT8 bytes
READ BYTES8 bytes
WRITE BYTES8 bytes
PUBLISHED BYTES8 bytes
RECEIVED BYTES8 bytes
ALLOCATED BYTES8 bytes
CONSUMED BYTES8 bytes
INSERT REQUESTS8 bytes
SET REQUESTS8 bytes
QUERY REQUESTS8 bytes
GET REQUESTS8 bytes
UPDATE REQUESTS8 bytes
PURGE REQUESTS8 bytes
LIST REQUESTS8 bytes
INFO REQUESTS8 bytes
STAT REQUESTS8 bytes
STATS REQUESTS8 bytes
PUBLISH REQUESTS8 bytes
SUBSCRIBE REQUESTS8 bytes
UNSUBSCRIBE REQUESTS8 bytes
CONNECTIONS REQUESTS8 bytes
CONNECTION REQUESTS8 bytes
CHANNELS REQUESTS8 bytes
CHANNEL REQUESTS8 bytes
WHOAMI REQUESTS8 bytes

CONNECTION

This request can retrieve metadata about specific connection.

Required fields

Request type

The first byte must be 0x15.

Connection index

The index contained in 4 bytes.

Response

This server resolve this request, initially, by sending 1 byte response.

If index exists then will also include fixed 235 bytes:

FieldSize
ID16 bytes
IP VERSION1 byte
IP16 bytes
PORT2 byte
CONNECTED AT8 bytes
READ BYTES8 bytes
WRITE BYTES8 bytes
PUBLISHED BYTES8 bytes
RECEIVED BYTES8 bytes
ALLOCATED BYTES8 bytes
CONSUMED BYTES8 bytes
INSERT REQUESTS8 bytes
SET REQUESTS8 bytes
QUERY REQUESTS8 bytes
GET REQUESTS8 bytes
UPDATE REQUESTS8 bytes
PURGE REQUESTS8 bytes
LIST REQUESTS8 bytes
INFO REQUESTS8 bytes
STAT REQUESTS8 bytes
STATS REQUESTS8 bytes
PUBLISH REQUESTS8 bytes
SUBSCRIBE REQUESTS8 bytes
UNSUBSCRIBE REQUESTS8 bytes
CONNECTIONS REQUESTS8 bytes
CONNECTION REQUESTS8 bytes
CHANNELS REQUESTS8 bytes
CHANNEL REQUESTS8 bytes
WHOAMI REQUESTS8 bytes

CHANNELS

This request can list channels.

Required fields

Request type

The first byte must be 0x16.

Response

This server resolve this request, initially, by sending 8 bytes response.

FieldSize
FRAGMENTS (P)8 bytes

After that we receive P fragments in 16 bytes:

FieldSize
FRAGMENT8 bytes
NUMBER OF SCOPED CHANNELS (Q)8 bytes

Per Q we are going to receive fixed 21 bytes:

FieldSize
CHANNEL SIZE (QL)1 byte
READ BYTES8 bytes
WRITE BYTES8 bytes
SUBSCRIBED CONNECTIONS4 bytes

At the end of the fragment we are going receive the keys in R bytes (sum of QL):

FieldSize
CHANNELQL bytes

CHANNEL

This request can provide metrics for specific channel.

Required fields

Request type

The first byte must be 0x17.

Size of channel

Is the quantity of chars (M) used by the key. Contained in 1 byte.

Channel

Is the channel name. Contained in M bytes.

Response

This server resolve this request by sending 1 byte response.

If the byte is 0x01 then will also include 4 bytes more:

FieldSize
NUMBER OF SUBSCRIBERS (Q)8 bytes

Per Q we need to read 28 bytes:

FieldSize
CONNECTION ID16 bytes
SUBSCRIBED_AT8 bytes
READ BYTES8 bytes
WRITE BYTES8 bytes

WHOAMI

This request can provide the index of the current connection.

Required fields

Request type

The first byte must be 0x18.

Response

This server resolve this request, by sending the connection ID in 16 bytes.

Last Updated:: 6/2/25, 10:11 PM
Contributors: Ian Torres