Manual Chapter : Implementing Low-Latency Electronic Trading with FIX load balancing

Applies To:

Show Versions Show Versions

BIG-IP AAM

  • 13.0.1, 13.0.0

BIG-IP APM

  • 13.0.1, 13.0.0

BIG-IP Link Controller

  • 13.0.1, 13.0.0

BIG-IP Analytics

  • 13.0.1, 13.0.0

BIG-IP LTM

  • 13.0.1, 13.0.0

BIG-IP AFM

  • 13.0.1, 13.0.0

BIG-IP PEM

  • 13.0.1, 13.0.0

BIG-IP DNS

  • 13.0.1, 13.0.0

BIG-IP ASM

  • 13.0.1, 13.0.0
Manual Chapter

Overview: Configuring low-latency electronic trading with FIX load balancing

You can configure the BIG-IP® system to manage electronic trading traffic for both low-latency and intelligent load balancing. The BIG-IP system supports Financial Information eXchange (FIX) protocol connections for electronic trading between financial institutions. When you acquire a special license, you can use the FastL4 profile to optimize the FIX connections, and use the embedded Packet Velocity® ASIC (ePVA) to minimize the latency. You can then use an iRule to implement intelligent load balancing: you do this by enabling the Late Binding feature in the FastL4 profile, then creating an iRule that parses each FIX header to choose a back-end server pool.

About Late Binding

With the Late Binding feature enabled, an iRule can examine the FIX logon packet, the one that establishes the connection, and choose a server pool based on the packet's contents. The iRule finishes by sending the connection down to the ePVA hardware, which processes the stream at high speed.

The only TCP options available to the client and server are MSS, accept Selective ACK, and Time Stamp. The BIG-IP system ignores all other options because it must enable SYN cookies on the client-side interface, and because the ePVA hardware does not slow down for any of those options. For example, the BIG-IP system ignores the Window Scaling option as soon as the flow has been released to the ePVA hardware.

Note: Secure Sockets Layer (SSL) is not supported by a virtual server that uses Late Binding.

About FIX features with low latency

After the iRule selects a server, the ePVA hardware manages the FIX stream for the rest of its existence. The ePVA does not examine the individual FIX packets that pass through it, so FIX-profile features such as tag substitution are not supported.

About induced latency for FIX connections

Induced latency, which is the latency realized after a FIX connection is established, typically has a duration of approximately 10 µsecs or less.

About using TCP protocol for FIX clients and servers

The ePVA only supports the TCP protocol, which requires FIX clients and servers to establish TCP connections. When creating a virtual server to manage the traffic for low-latency electronic trading, you must specify the TCP protocol setting.

Task summary

There are several tasks you perform to implement low-latency electronic trading.

Task list

Licensing low-latency electronic trading functionality

In order to use a BIG-IP® system to manage low-latency electronic trading functionality, you must first acquire a specific license. The license must enable both of the following features:
  • Advanced LTM® Protocols
  • FIX Low Latency

Please contact your F5® Networks support representative to acquire the necessary license.

Creating a custom Fast L4 profile for FIX

You can create a custom Fast L4 profile to manage Layer-4 traffic for FIX.
  1. On the Main tab, click Local Traffic > Profiles > Protocol > Fast L4 .
    The Fast L4 screen opens.
  2. Click Create.
    The New Fast L4 profile screen opens.
  3. In the Name field, type a unique name for the profile.
  4. Select the Custom check box.
  5. Set the PVA Acceleration field to Guaranteed.
  6. If you plan to use Late Binding and either of the Loose Initiation and Loose Close check boxes are enabled, clear them both.
    The Late Binding feature examines the first few packets in the FIX stream, and the Loose Initiation feature makes it possible to skip those packets without any examination.
  7. Set the TCP Close Timeout setting, according to the type of traffic that the virtual server will process.
  8. Disable the Hardware SYN Cookie Protection feature by clearing the check box.
  9. Enable the Software SYN Cookie Protection feature by selecting the check box.
  10. The Late Binding feature makes it possible to choose a server pool based on data in the FIX header. An iRule in the virtual server parses the FIX header and selects the server pool. Select the check box to enable Late Binding.
    1. You can allow the iRule to explicitly determine when the flow is released from Layer 7 down to Layer 4. The iRule code can then perform additional computation before binding the connection to Layer 4. Enable this by selecting the Explicit Flow Migration check box. When this feature is enabled, the flow is not released to Layer 4 until the iRule invokes the BIGTCP::release_flow command.
      By default, this is disabled and the flow drops down to Layer 4 immediately after the connection to the server is established.
    2. Use the Client Timeout field to determine how much time to allow for any client to send the first 2144 bytes of Layer 7information. In normal cases, this amount of data arrives immediately.
    3. From the Timeout Recovery list, select an action that the profile should take in case of timeout. Select Disconnect to drop the connection summarily, or select Fallback to process the packet without parsing the Layer 7 fields. The fallback option sends any timed-out connection to the Virtual Server's default pool.
  11. Click Finished.
The custom Fast L4 profile appears in the list of Fast L4 profiles.

Creating a FIX profile for low-latency electronic trading

A virtual server with Late Binding enabled can choose a server pool based on the contents of the FIX connection's initial packet. The Late Binding feature makes it possible to combine this load balancing with low latency.
Note: This is a simplified FIX profile. The low-latency path goes through the ePVA hardware, which does not examine the contents of each FIX packet. The only packet that the BIG-IP software examines is the logon packet, which the BIG-IP® system uses to choose a server pool. Therefore, most of the features in the FIX-profile screen (such as tag substitution) are ignored for low-latency trading.
  1. On the Main tab, click Local Traffic > Profiles > Services > FIX .
    The FIX profile list screen opens.
  2. Click Create.
    The New FIX Profile screen opens.
  3. In the Name field, type a unique name for the profile.
  4. From the Parent Profile list, select a parent profile.
  5. Select the Custom check box.
  6. Optional: From the Report Log Publisher list, select the publisher for error messages and status reports.
  7. Optional: From the Message Log Publisher list, select the publisher for message logging.
  8. Click Finished.
The FIX profile is configured for low-latency electronic trading with FIX load balancing.

Creating a pool

You can create a pool of servers that you can group together to receive and process traffic.
  1. On the Main tab, click Local Traffic > Pools .
    The Pool List screen opens.
  2. Click Create.
    The New Pool screen opens.
  3. In the Name field, type a unique name for the pool.
  4. Using the New Members setting, add each resource that you want to include in the pool:
    1. (Optional) In the Node Name field, type a name for the node portion of the pool member.
    2. In the Address field, type an IP address.
    3. In the Service Port field, type a port number, or select a service name from the list.
    4. (Optional) In the Priority field, type a priority number.
    5. Click Add.
  5. Click Finished.
  6. Repeat these steps for each pool you want to create.
The new pool appears in the Pools list.

Creating an iRule for load-balancing Layer-7 (FIX) traffic

Creating an iRule for load-balancing Layer-7 (FIX) traffic requires that the Late Binding feature is enabled in the Fast L4 profile. A virtual server with Late Binding enabled can choose a server pool based on the contents of the FIX connection's initial logon packet(s).
You can create an iRule that reads the FIX logon fields and directs each TCP stream to a different server pool based on the field settings.
  1. On the Main tab, click Local Traffic > iRules .
    The iRule List screen displays a list of existing iRules®.
  2. Click the Create button.
    The New iRule screen opens.
  3. In the Name field, type a unique name for the iRule.
  4. In the Definition field, type an iRule to match FIX fields and choose a server pool based on their settings.
    Use the FIX_HEADER iRule event to select the first five fields in a FIX packet:
    • BeginString
    • BodyLength
    • MsgType
    • SenderCompID
    • TargetCompID

    The total length of a FIX message is unbounded, so this ensures that you capture all of the relevant data to choose a back-end server pool without waiting to collect all of the FIX message.

    For example, this iRule sends messages from each of three senders to a specific server pool. Messages from any other senders revert to the default pool in a virtual server that uses this iRule. The iRule also logs a message to indicate that a new FIX stream has opened:
    when FIX_HEADER {
        set MsgType [FIX::tag get 35]
        if { $MsgType eq "A" } {  # an A message is a logon message
            # record the sender and the target
            set SenderCompID [FIX::tag get 49]
            set TargetCompID [FIX::tag get 56]
            
            # log the event locally - a new FIX stream is being created
            log "FIX header: Sender $SenderCompID, Target $TargetCompID"
            
            # log the event with High Speed Logging (HSL), too
            set hsl [HSL::open -proto UDP -pool syslog_server_pool]
            HSL::send $hsl "[IP::client_addr]: Sender $SenderCompID, Target $TargetCompID\n"
            
            # choose a server pool based on the name of the sender
            switch $SenderCompID {
                "Fred's Bank"   { pool FIX1 }
                "Wilma's Bank"  { pool FIX2 }
                "Barney's Bank" { pool FIX3 }
            }
        }
    }                
    The iRule may be able to explicitly send the flow down to the ePVA, rather than doing it automatically. This explicit control is only possible if you set it in the Fast L4 profile. In the following example, the rule does not release the flow unless it encounters a FIX packet from a sender named "Mr. Slate's Bank". You must release the flow on both the client side (with the CLIENT_ACCEPTED event) and the server side (in the SERVER_CONNECTED event):
    when CLIENT_ACCEPTED {
        # prepare for releasing the flow down to the ePVA
        BIGTCP::release_flow
    }
    
    when FIX_HEADER {
        # (same as above example, with an additional sender)
        set MsgType [FIX::tag get 35]
        if { $MsgType eq "A" } {  # an A message is a logon message
            # record the sender and the target
            set SenderCompID [FIX::tag get 49]
            set TargetCompID [FIX::tag get 56]
            
            # log the event - a new FIX stream is being created
            log "FIX header: Sender $SenderCompID, Target $TargetCompID"
            
            # choose a server pool based on the name of the sender
            switch $SenderCompID {
                "Fred's Bank"      { pool FIX1 }
                "Wilma's Bank"     { pool FIX2 }
                "Barney's Bank"    { pool FIX3 }
                "Mr. Slate's Bank" { pool FIX4 }
            }
        }
    }
    
    when SERVER_CONNECTED {
        if {$SenderCompID eq "Mr. Slate's Bank"}{ 
            # Mr. Slate's Bank sent this, so lower the latency
            log local0. "Detected $SenderCompID - releasing flow to ePVA"
            BIGTCP::release_flow
        }
    }                   

    The previous code sends all FIX streams through standard FIX-profile processing except the one(s) from "Mr. Slate's Bank", which goes through the ePVA.

  5. Click Finished.
The iRule is now available. You can use this iRule in a virtual server that also offers a FIX profile and the low latency of Fast L4.

Creating a virtual server for low-latency electronic trading

After you create a server pool, profile(s), and (optionally) iRule, you need to create a virtual server that references those components.
  1. On the Main tab, click Local Traffic > Virtual Servers .
    The Virtual Server List screen opens.
  2. Click the Create button.
    The New Virtual Server screen opens.
  3. In the Name field, type a unique name for the virtual server.
  4. From the Type list, select Performance (Layer 4).
  5. In the Destination Address field, type the IP address in CIDR format. This is the address to which the FIX clients send their FIX transmissions.
    The supported format is address/prefix, where the prefix length is in bits. For example, an IPv4 address/prefix is 10.0.0.1 or 10.0.0.0/24, and an IPv6 address/prefix is ffe1::0020/64 or 2001:ed8:77b5:2:10:10:100:42/64. When you use an IPv4 address without specifying a prefix, the BIG-IP® system automatically uses a /32 prefix.
    Note: The IP address you type must be available and not in the loopback network.
  6. From the Configuration list, select Advanced.
  7. From the Protocol list, select TCP.
  8. From the Protocol Profile (Client) list, select the custom Fast L4 profile you defined for low-latency FIX trading.
  9. Go to the FIX Profile list and select the custom FIX profile you defined for low-latency trading.
  10. Optional: For the Address Translation setting, clear the Enabled check box to implement direct server return (DSR) functionality.
  11. Optional: For the Port Translation setting, clear the Enabled check box.
    Important: Clearing the Enabled check box disables network address translation (NAT) functionality. If you require NAT, you must select the Enabled check box.
  12. In the Resources area of the screen, from the Default Pool list, select the pool name for FIX streams.
    This pool is for streams that do not match your iRule(s).
  13. For the iRules setting, from the Available list, select the name of the iRule that you created for the Late Binding feature and move it to the Enabled list.
    The iRule enables load balancing based on the Layer-7 (FIX) fields at the head of each stream.
  14. Click Finished.
The virtual server is configured to use the specified Fast L4 profile and pool. If a client initiates a FIX connection with this virtual server, the connection uses the Fast L4 (ePVA) hardware.

Implementation result

This implementation configures a BIG-IP® system to manage low-latency electronic trading functionality, optimizing the system for predictable latency and jitter. Clients who send FIX streams to the virtual server's Destination address all receive this low-latency service. The virtual server intelligently distributes the streams to different server pools based on information in each stream's FIX logon packet.