Well, I suppose this is a more theoretical question for those familiar with hft. I receive orders from FAST and process them. I get about 2-3 thousand orders per second. The question is whether I should try to process them synchronously or asynchronously.
Each time I receive the following order, I need to do the following:
- update the order book of the corresponding tool
- update indices and indicators that depend on this order
- update strategies and plan some actions if necessary (buy / sell something, etc.).
To do this, I have about 200-300 μs synchronously (to process 3000 orders per second). I think that should be enough.
Just to schedule the asynchronous task that I spent, I think, ~ 30 μs
Advantages and disadvantages:
Synchronous:
- ++ no need to sync things!
- ++ The delay between “receiving an order” and “taking actions” is less because you do not need to schedule tasks or transfer data / work to another process (very important in hft!).
- - however, the “order received” action may be delayed, because we can wait in the socket buffer, waiting for the previous processing
Asynchronous:
- ++ ability to use the power of modern servers (for example, my server has 24 cores)
- ++ is faster in some scenarios because you don’t wait while the previous message is being processed.
- ++ can handle more messages or can do more “complex” things for each message.
- - you need to synchronize a lot of things, which can slow down the program
: MSFT, INTC . NASDAQ. NASDAQ .
, ... .
, , . , . (MSFT INTC), (MSFT) .