MHC Whitepaper – The primary cause of latency in exchanges

MHC Whitepaper – The primary cause of latency in exchanges
20/09/2016 MHC
The primary cause of latency in exchanges

This white paper explains how exchanges can understand whether the primary cause of latency across their trading systems is the queuing formed when messages arrive at the matching engine at a rate which exceeds their ability to process them, or whether there are other underlying causes which they need to address.

 

Overview of queuing related latency

High frequency traders and market makers listen to and process the same news and market data feeds from the same organisations and not surprisingly, they reach the same conclusions: that the market is going to move and they need to react so they move with it.  Traders react by attempting to submit orders at the now out of date price before the market moves in order to make a quick profit and others react by pulling any resting orders in an attempt to prevent these trades from being made against them.

The exchange, on the receiving end of this activity, receives a burst of messages arriving through their gateways at a rate which exceeds their ability to process them, so a backlog, or queue, forms of messages waiting to be processed.  This queue builds and builds with messages that will be processed in sequence, so messages arriving later experience significant delay before they reach the front of the queue.

From the trader’s viewpoint, this is latency which they interpret as risk.  In not having the confidence that an order will be processed when it’s submitted they feel exposed to the risk that trades will be made against them.  So for instance, if a trader has submitted a pull order to the exchange and it isn’t processed immediately then in that period while they are waiting there is the possibility that another trade will match against them at the old price.

Traders don’t like this latency because it causes risk, but equally, exchanges don’t like this latency because it costs them in terms of lost trades.  At the very instant when the market is moving by sufficient margin to cause traders to submit orders, they can’t execute them because they’re not fast enough.  Added to this loss is the reduction in trades they get by more cautious traders completely withdrawing from the market in advance of expected latency in an attempt to avoid the risky periods.

 

Is queuing the primary cause of latency?

The key to understanding whether queuing is the primary cause of latency across an exchange matching engine is to recognise that, although messages vary in size and time taken to process, given enough messages the average time to process a message regresses towards a mean value.  Exchanges can therefore use this mean processing time to calculate the average throughput of their matching engines, which in turn allows them to model the behaviour of the engine and from that understand whether specific times of latency fit this way of modelling their queuing, or whether there are other underlying causes which they need to address.

The throughput of a matching engine can be calculated as the number of messages processed divided by the time taken to process them, with the proviso this calculation can only be used while the matching engine is busy, otherwise the calculated throughput will be significantly lowered by the waiting time when no messages are being processed.  On a matching engine the busy periods may only equate to about 1% of the day, but they are the only periods that concern us here.

Looking at all the queues that occur on a matching engine, the shortest queues will show a wide variation in throughput because a few large or small messages will produce a significant change in the calculated throughput.  The queues that take the longest to process will show a small variation in throughput because the effect of the small or large messages will be insignificant compared with the large numbers of more average messages.

The above scatter graph of all these queues showing throughput vs. time taken to process the queue gives distinctive pattern where it can be seen that the throughput for the matching engine during busy periods regresses towards a mean value.

There may, however, be other reasons for latency across the matching engine, but these will show up on the graph in a different pattern.  The graph below shows two such examples, one where what looks like a single message has been delayed for an excessive amount of time (it looks like a queue with very low throughput) and another underlying pattern where throughput slows considerably below the expected mean.

Conclusion

The method described above allows exchanges to determine whether, of the multiple causes of latency that traders experience when submitting orders, delays caused by queuing are the primary, or even the only cause of significant latency being experienced.  Exchange matching engines do not experience any performance degradation during these periods but instead execute at their normal processing rate.  The problem is that if messages arrive at the matching engine at a rate which exceeds their ability to process them, a queue will form and thus latency occurs.

While nothing is certain without actually working through the detailed processing of a group of messages, if it looks and behaves like a queue, it probably is a queue.

 

About Mansion House Consulting

MHC is an international business and technology consultancy, focused exclusively on the financial services sector. We provide high quality, practical and robust solutions for the industry through our team of highly experienced consultants and subject matter experts.

We specialise in change and transformation management, toolkits, regulatory and governance frameworks. We deliver solutions globally to the transaction and investment banking communities, including leading Tier One clients from the financial services industry.

We have a niche expertise in Capacity, Performance and Event Management, Application Monitoring and Data Centre Optimisation Services. We provide both outcome based propositions and managed service solutions.

Established in 2009 we have been expanding and evolving ever since, with a team in excess of 300 and listed in the Sunday Times Tech Track 100 on three consecutive years, the London Stock Exchange’s 1000 Companies to Inspire Britain 2015 as well as the Investec Mid-Market 100 list in 2016. Headquartered in London, we have a global presence through offices in Frankfurt, Singapore, New York, Jacksonville (Florida) and Bangalore (India).

To find out more about our services, explore our website www.mansion-house.co.uk or contact:

info@mansion-house.co.uk

 

Disclaimer

This publication has been prepared for general guidance on matters of interest only, and does not constitute professional advice. You should not act upon the information contained in this publication without obtaining specific professional advice. No representation or warranty (express or implied) is given as to the accuracy or completeness of the information contained in this publication, and, to the extent permitted by law, the Mansion House Consulting Limited Group, its members, employees and agents do not accept or assume any liability, responsibility or duty of care for any consequences of you or anyone else acting, or refraining to act, in reliance on the information contained in this publication or for any decision based on it.

© 2016 Mansion House Consulting Limited. All rights reserved.

In this document, “MHC” refers to the UK entity, and may sometimes refer to the MHC group network. Each MHC entity is a separate legal entity. Please see www.mansion-house.co.uk for further information.