Skip to content

SBE Quick Guide

Jay Santamaria edited this page May 8, 2025 · 5 revisions

Overview:

SBE is designed by FIX Trading company, which is industry standard trading protocol designed for high frequency trading.

Index:

Dependencies for SBE

The SBE Tool does not have a dedicated Maven plugin. So we need to add few dependencies and configurations as follows:

  • Insert the agrona dependency in the pom.xml file to allow maven to run SBE.
    <dependency>
           <groupId>org.agrona</groupId>
           <artifactId>agrona</artifactId>
	   <version>1.9.0</version>
    </dependency>
  • Add the configuration in the pom.xml file as mentioned below, we use sbe 1.20.4 version in our project.

How SBE works?

  • To use SBE tool we need to define the SBE message schema, which is an XML file.

  • SBE message schema contains the structure of the SBE message and defines all the possible attributes CTS-Base-sbe.xml

  • We define the encode method, in which we use an unsafe buffer to encode the message and message header encoder to encode all the attributes of the message into a single SBE message.

  • To decode we use unsafebuffer to wrap the message into payload decoder and extract the message.

  • Further we get each value of the payload decoder and create transaction payload.

How SBE is defined:

Validation of Messages:

  • Validation of SBE messages is performed at every hop from creating a tender to finding a match and responding back with match id. We can achieve this by printing the message at every hop before encoding the message and after decoding the message.

  • To print the message we use toString method in payloads classes under controllers.

  • This will help us to track the message at every step, sample snapshot as follows.

  • Now if we cross verify we can validate the message at the encoder end. and the decoder end to validate the message.

  • Using the example of EiCreateTenderPayload, we can use the SBE-generated toString() method to interpret the raw ByteBuffer into a human-readable format. We can then compare this against the toString() output of the original Java payload object to verify that the encoding and decoding processes preserve data integrity.

  • This hex dump and decoded layout represent a serialized EiCreateTenderPayload message using SBE. Each field is mapped to its byte range and decoded value, verifying that the encoded buffer matches the expected payload structure. The expiration time and interval timestamps confirm proper Instant encoding, while fields like side, quantity, and price demonstrate that numeric and enum types are correctly represented. The Full Raw Buffer shows the actual bytes transmitted over the wire. This output can be used to visually validate correctness of the encoding process at a low level.

Evaluation of SBE:

  • We benchmarked EiCreateTenderPayload using both JSON and Simple Binary Encoding (SBE). SBE completed 1 million operations in 190.99ms (0.19µs/op), while JSON took 6635.37ms (6.64µs/op)—showing SBE is nearly 35x faster. These results validate our SBE encoder/decoder implementation, highlighting major improvements in speed, memory efficiency, and suitability for high-performance energy market messaging in EML-CTS.

Few useful references:

Clone this wiki locally