1/7 Problem: How to scale trading/liquidation engines up to 500k/1M/10M users? 100k users are manageable, but eventually single threaded architecture will bottleneck growing number of users.https://twitter.com/paoloardoino/status/1238965074427088903 …
-
Show this thread
-
2/7 * The order book (OB) for each pair is run on a single thread, with its own I/O queues. * User data UD is deterministically sharded among different threads * Liquidation engine (LE) is a set of threads with direct mem access to user data threads (positions, balances, ..)
1 reply 0 retweets 6 likesShow this thread -
3/7 * LE interacts with OB via in-mem priority queue. * LE adds to a liquidation-order (LEO) enough meta-info for the order book thread to evaluate if liquidation should still happen, bankruptcy price, ...
1 reply 0 retweets 4 likesShow this thread -
4/7 * Each LE sorts users by risk (probability of getting liquidated). * Improvement: a single shared sorted map can be generated across the threads
5 replies 0 retweets 5 likesShow this thread -
5/7 * Depending on the size of the position to be liquidated, LEO can be run into the book or positions can be acquired by the system and sold via more complex algos. We call it liquidation stages (LS).
1 reply 0 retweets 5 likesShow this thread -
6/7 * When a LEO gets processed, the OB thread evaluates (querying UD) if the user should still be liquidated and using which LS. * We tested this system with 100sK users + apocalyptic cascading liquidations and ended up always in ensuring the 0-sum game
1 reply 1 retweet 9 likesShow this thread -
7/7 * Complexity of this solution relies in write tests (we have more than 1000 automated simulations running) * Happy to elaborate if not really clear. * These are the types of solutions used in huge brokers with M of customers. No much way around it.
4 replies 1 retweet 17 likesShow this thread -
Replying to @paoloardoino
Have you guys got to the point where you are turning off other cores on CPUs to make cache misses less likely? I know HFTs commonly do this not sure about the exchange side
1 reply 0 retweets 0 likes
Do not. Our approach is scaling horizontally -> 1 CPU per product possibly.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.