• Stars
    star
    145
  • Rank 245,865 (Top 5 %)
  • Language
    Java
  • License
    Other
  • Created over 10 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Falcon, the open source ultra low-latency FIX engine for Java

Falcon

Falcon is a high performance, low latency FIX engine for the JVM. It provides an API that enables FIX connectivity for both buy side and sell side applications such as trading systems and order management systems.

The engine is designed to avoid heap allocations on the TX and RX paths to avoid GC pauses that are disastrous for low-latency applications. The engine is packed with other optimizations such as avoiding querying the system clock for every message and open-coding formatting and parsing functions where the JRE allocates memory implicitly.

Falcon is able to achieve 8 µs RTT on when running the latency tester client and server on the same machine.

Features

  • Zero-copy, non-blocking, low-latency NIO networking
  • Low heap allocation rate in the FIX engine core
  • Small memory footprint for session and message data structures

Example

An example application that sends 100000 NewOrderSingle messages looks like this:

import static java.net.StandardSocketOptions.*;
import java.nio.channels.*;
import java.net.*;
import java.nio.*;

import static falcon.fix.MessageTypes.*;
import static falcon.fix.Versions.*;
import static falcon.fix.Tags.*;
import falcon.fix.*;

public class Example {
  public static void main(String[] args) throws Exception {
    SocketChannel socket = connect("localhost", 7070);

    Session session = new Session(socket, FIX_4_2, "HERMES", "INET");

    session.updateTime();

    session.send(new Message.Builder(Logon)
        .add(new Field(EncryptMethod, "0" ))
        .add(new Field(HeartBtInt,    "30"))
        .build());

    Message newOrder =
      new Message.Builder(NewOrderSingle)
          .add(new Field(EncryptMethod, "0" ))
          .add(new Field(HeartBtInt,    "30"))
          .build();

    for (int i = 0; i < 100000; i++) {
      if ((i % 10000) == 0) {
        session.updateTime();
      }
      session.send(newOrder);
    }

    session.updateTime();

    session.send(new Message.Builder(Logout).build());

    socket.close();
  }

  private static SocketChannel connect(String host, int port) throws Exception {
    InetSocketAddress addr = new InetSocketAddress(host, port);
    SocketChannel socket = SocketChannel.open();
    socket.configureBlocking(false);
    socket.setOption(TCP_NODELAY, true);
    socket.connect(addr);
    socket.finishConnect();
    return socket;
  }
}

Performance

The FIX engine has been measured to have 8 µs RTT for a loopback ping-pong test where client sends a NewOrderSingle message and waits for an ExecutionReport message to arrive. The numbers include the time spent in Linux TCP/IP stack and the loopback device.

To reproduce the results, first download and build Libtrading. Then start the FIX performance test server:

$ taskset -c 0 tools/fix/fix_server -m 1 -p 7070

Finally, run the Falcon latency tests:

$ ./falcon-perf-test/bin/falcon-perf-test 1000000
87693.5 messages/second
min/avg/max = 9.8/11.4/19935.3 µs
Percentiles:
  1.00%: 10.15 µs
  5.00%: 10.51 µs
 10.00%: 10.61 µs
 50.00%: 11.12 µs
 90.00%: 11.90 µs
 95.00%: 13.27 µs
 99.00%: 14.53 µs

License

Copyright © 2013-2015 Pekka Enberg and contributors

Falcon is distributed under the 2-clause BSD license.

More Repositories

1

awesome-low-latency

Patterns and resources of low latency programming.
314
star
2

fjord

Fjord, F# programming language for the JVM.
Java
200
star
3

helix

Helix, a market data feed handler for C and C++.
C++
104
star
4

mvcc-rs

Optimistic multi-version concurrency control (MVCC) for main memory databases, written in Rust.
Rust
76
star
5

awesome-os

A curated list of resources on operating system design and implementation.
75
star
6

unix-history

History of UNIX Design and Interfaces
57
star
7

hornet

Hornet, a JVM optimized for low-latency applications.
C
54
star
8

vsr-rs

Viewstamped Replication for Rust
Rust
38
star
9

go-osxhv

Go bindings for the OS X Hypervisor.framework API
Go
36
star
10

pstore

pstore, a high-performance, read-optimized database system.
C
25
star
11

ustat

ustat - an unified system stats collector tool
Go
23
star
12

sphinx

Sphinx is a fast in-memory key-value store, compatible with Memcached.
C++
20
star
13

ycsb-rs

A Rust port of Yahoo! Cloud Serving Benchmark (YCSB)
Rust
20
star
14

linux-networking

Notes on Linux network internals
18
star
15

godoom

A Doom clone written in OpenGL and Go.
Go
17
star
16

awesome-databases

Databases are awesome! 🕶
17
star
17

wolf

Wolf, a raycasting engine for pseudo 3D games.
C
13
star
18

nasdaq-omx-simulator

NASDAQ OMX simulator
Go
12
star
19

bwtree-rs

Bw-Tree for Rust
Rust
12
star
20

legacy-free-x86

OS development resources for legacy-free x86 hardware.
7
star
21

classpath

Pekka's GNU Classpath development tree
Java
7
star
22

duhview

ANSI art viewer written in C and SDL
C
6
star
23

awesome-serverless

Serverless is awesome! 🕶
6
star
24

go-scylla-api

Go library for accessing the Scylla REST API
Go
6
star
25

bitmex-api

BitMEX API for C++
C++
6
star
26

groovyfmt

groovyfmt is a tool to automatically format your Groovy code.
GAP
6
star
27

multiplayer-matchmaker

A multiplayer on-line game matchmaking server.
TypeScript
5
star
28

nasdaqomx-itch

Haskell implementation of NASDAQ OMX Nordic ITCH
Haskell
5
star
29

spirit

Rust
4
star
30

posixbench

POSIX latency and energy-efficiency benchmark suite
C++
3
star
31

btct

Bitcoin terminal for monitoring real-time Bitcoin quotes on the command line.
Ruby
3
star
32

yetanothercore

Yet another RISC-V CPU core
C
2
star
33

alp

Alp, a text-mode email client.
Ruby
2
star
34

scyllactl

Go
2
star
35

scylla-fedora

1
star
36

esparser-rs

JavaScript and TypeScript parser for 🦀
Rust
1
star
37

virt-net-perf

1
star
38

xmlindent

C
1
star