Introducing 'Hive' - A distributed matching engine for digital asset trading
This week Bitfinex deployed Hive — a distributed, multi-threaded & multi-process matching engine built around speed, stability and scalability. A matching engine is the core software behind an electronic, computer-driven trading platform like Bitfinex. A far cry from rowdy floor traders, cryptocurrency trading (and that of most other financial instruments) is now almost entirely enabled by electronic matching engines and the software supporting this. Matching engines work by matching up trades on a platform, allocating bids and offers amongst competing traders by means of certain set of rules (algorithms). Through an increasingly efficient order allocation process, electronic matching engines have worked to drive down transaction fees to pennies whilst improving market quality (lower spreads, improved order book depth).
Hive, Matching Engine, Electronic trading, Algorithmic trading, Electronic Matching Engine
16589
post-template-default,single,single-post,postid-16589,single-format-standard,bridge-core-3.0.6,et_bloom,qode-page-transition-enabled,ajax_fade,page_not_loaded,,qode-title-hidden,qode_grid_1300,footer_responsive_adv,qode-content-sidebar-responsive,qode-child-theme-ver-1.0.0,qode-theme-ver-29.3,qode-theme-bridge,qode_header_in_grid,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Introducing ‘Hive’ – A distributed matching engine for digital asset trading

This week’s performance update was focused around the deployment of Hive — a distributed, multi-threaded & multi-process matching engine built around speed, stability and scalability.

Introducing 'Hive' - a distributed matching engine built to scale.

 

Electronic Matching Engines

A matching engine is the core software behind an electronic, computer-driven trading platform like Bitfinex. A far cry from rowdy floor traders, cryptocurrency trading (and that of most other financial instruments) is now almost entirely enabled by electronic matching engines and the software supporting this.

Matching engines work by matching up trades on a platform, allocating bids and offers amongst competing traders by means of certain set of rules (algorithms). Through an increasingly efficient order allocation process, electronic matching engines have worked to drive down transaction fees to pennies whilst improving market quality (lower spreads, improved order book depth).

As a by-product of this, the speed at which one can receive, interpret and react to market information, in both relative and absolute terms, is now a fundamental consideration for both traders and exchanges seeking a competitive advantage.

 

Introducing ‘Hive’

Recent platform updates on Bitfinex have focused on transitioning away from a single-threaded matching engine towards a distributed, high-performance, multi-process system.

Referred to as Hive, this system allows for increasingly efficient order execution & improved scaling capabilities by separating workloads amongst multiple ‘instances’, or workers. Instances communicate via Grenache to allocate and execute trades, spawning new workers in times of high load (and vice versa).

 

Engine Performance Improvements

Due to improvements brought on by Hive, traders on Bitfinex now react more quickly to price movements and changing market conditions. The new architecture enables Bitfinex to maintain high performance in the face of a growing user base, new tradable assets and unforeseen spikes in trading activity.

The distribution of the matching engine ensures that order matching capacity (and latency) remains unaffected by periods of high order throughput. This minimises chances of order rejection due to system overload, even under heavy load.

In internal testing, Hive has scaled up to 100x the number of orders handled in the current market. The deployment of Hive has resulted in a complete order execution time of 14ms, down 10x relative to pre-deployment. This includes the pre-risk check (heaviest part), order matching (microseconds) and execution reporting. Theses results are based on initial tests and are likely to improve further as we work to optimise Hive integration.

Hive also comes with full support for new order types (e.g. position reduce-onlymarginorders), order level flags to prevent self-trading, FX virtual books and support for a number of additional gateways, including Ethfinex DEX gateway and FIX.

 

The Decentralisation of Ethfinex

On the topic of Ethereum, Hive puts the groundwork in place for the decentralisation of Ethfinex. Through adding support for expiry times for orders into the engine — a necessary component for the matching of 0x format, non-custodial orders — as well as adding several other flags, the road is paved for the launch of the Ethfinex non-custodial API and decentralised trading portal.

A new gateway API will allow these Ethereum based order promises (signed and authenticated using a trader’s private key) to be submitted into Hive and treated agnostically like any other order, up until the point of execution when they are settled with atomic swaps on Ethereum.

The deployment of Hive sets a new performance standard for digital asset trading engines and puts the groundwork in place for future development, decentralisation & scalability efforts.


Stay up to date with Bitfinex on TwitterLinkedInFacebook & Support.

All our development libraries are open-sourced. If you are interested in learning more about these, please visit our Github.

Join us on our mission to create the most innovative & industry-leading cryptocurrency exchange.