Live data from Hacker News

The LMAX Architecture - 100K TPS at Less than 1ms Latency

martinfowler.com

51–57 of 57 posts

Re: The LMAX Architecture - 100K TPS at Less than 1ms Latency

#51
post #47

Earlier quoted context omitted.

To abuse your analogy there are many fast drivers that have little to know mechanical knowledge. You seem to be under the impression that to be an authority one must have comprehensive and detailed knowledge, particularly in areas you care about. I believe this is rarely the case. It's far more important to understand the essential. The key to being a good leader is not to know everything better than everyone, but to…

> You seem to be under the impression that to be an authority one must have comprehensive and detailed knowledge, particularly in areas you care about. Detailed and comprehensive knowledge is exactly what I expect from an authority on a subject. If they don't have it, then on what basis are they considered an authority? It sounds to me - and I apologise if I've misunderstood - like you are arguing that a software arc…

> what I expect from an authority on a subject

It's about the subject area. Fowler is an expert on OO architecture, not low level optimization. I think you're holding him to the wrong standard, and I think it's rather absurd to insist that anyone has a duty to be what you think they should be professionally.

Re: The LMAX Architecture - 100K TPS at Less than 1ms Latency

#52

As usual, it depends on what you define as a "transaction". If you don't need ACID, I can probably jerry-rig something in C that'll give you hundreds of thousands of "transactions" per second. It may have problems with retrieving the data, but hey, look at that sucker go! OK. Time to be more reasonable. 1. Relaxed Guarantees There's no actual durability in the conventional spinning-rust sense. Instead you're hoping t…

Re: 1. There is no "hoping", the input disrupter garauntees a total ordering to events as written to a journal. this journal is then processed by BLPs. RE: atomiticity -- the BLP processes one message at a time, which ensures that you do not have multiple threads clashing, but you do not have MVCC or any form of rollback, which he addresses thusly: >LMAX's in-memory structures are persistent across input events, so i…

Single nodes can die in the system without issue. They often do! Since we use IP multicast the network failure is transparent as a replica takes up the primary role.

The one issue to be managed with this type of system is exceptions in the business logic thread. This can be handled via a number of prevention techniques. First, apply very strict validation on all input parameters. Second, take a test driven approach to development; at LMAX we have 10s of thousands of automated tests. Third, code so methods are either idempotent, or changes are only applied at the end when the business logic is complete using local variables. With this combination of approaches we have not seen a production outage due to business logic thread failure in over a year of live operation.

Re: The LMAX Architecture - 100K TPS at Less than 1ms Latency

#53
post #38
post #14

Cliff Click makes a good post [1] discussing the LMAX/Disruptor architecture and how it can give large performance gains in specific circumstances (such as those generally encountered by LMAX). In particular, Disruptor works best when there is a one-to-one ratio of disruptor threads and cpu cores. Great to see Cliff rolling up his sleeves and looking into this stuff from LMAX. Additionally Cliff points out that there…

Too bad there's been essentially zero activity on MRI for over a year.

A good posting showing the effect of setting thread affinity for version 1.0 of the Disruptor.

http://java.dzone.com/articles/java-threads-steroids

Re: The LMAX Architecture - 100K TPS at Less than 1ms Latency

#54
post #47

Earlier quoted context omitted.

> You seem to be under the impression that to be an authority one must have comprehensive and detailed knowledge, particularly in areas you care about. Detailed and comprehensive knowledge is exactly what I expect from an authority on a subject. If they don't have it, then on what basis are they considered an authority? It sounds to me - and I apologise if I've misunderstood - like you are arguing that a software arc…

> what I expect from an authority on a subject It's about the subject area. Fowler is an expert on OO architecture, not low level optimization. I think you're holding him to the wrong standard, and I think it's rather absurd to insist that anyone has a duty to be what you think they should be professionally.

The way I see it, they're linked. The memory hierarchy has a direct impact on a number of architectural concerns: data organisation, choice of components, communication patterns between components, etc. It can make the difference between a system that meets its functional requirements and one that doesn't. These are all things an architect is supposed to care about, so to me it seems reasonable to expect an expert architect to be aware of the factors influencing them. I get the feeling we're not going to agree about this though.

Re: The LMAX Architecture - 100K TPS at Less than 1ms Latency

#55

The article starts by saying that low latency is the main requirement for financial trading, but then quotes all performance numbers in throughput ("6 million orders per second"). I couldn't find any mention of average or worst-case latency, and throughput numbers alone tell you nothing about latency. In particular, since each input event has to be journaled and replicated (which both involve I/O) before it can be pr…

You are right predictable latency is key, but that is one of the big wins that we have found with the Disruptor and our surrounding infrastructure. The Disruptor is not the only thing that we have worked on to achieve this. For example we have spent time experimenting with journalling and clustering techniques to give us high-throughput, predictable, mechanisms for protecting our state.

As Martin said in his reply our system is implemented as a number of services, which communicate via pub-sub messaging, it is not quite as naive as you assume, we still have a distributed system. For the high-throughput, low latency functions of the system, (e.g. order matching in our exchange, or risk evaluation in our broker) they are each serviced on a single business logic thread, on separate servers.

Our latency measurements include these multiple hops within our network and represent an inbound instruction arriving at our network to the time that we have a fully processed, outbound, response back at the edge of our network, as Martin pointed out, modern networking can be quiet efficient when used well.

We have designed to allow us to shard our system when the need arises, but we are actually a long way away from that need. Even though these high performance services keep their entire working set in memory, that is still a relatively small number when compared to the amount of memory available in modern commodity servers. We currently have lots of head-room!

We think that this is a very scalable approach and under-used. Keeping the working set in memory is pretty straight forward for many business applications, and has the huge benefit of being very simple to code. Much more straight-forward than the, more conventional, shuffling of data around and translation from one form to another that is such a common theme in more conventional systems.

The sharding decision is simple, for our problem domain we have two obvious dimensions for sharding, accounts and order-books. Each instance (shard) would continue to have it's business logic processed on a single thread. I think that this is normal for most business problems, it is a matter of designing the solution to avoid shared state between shards.

We are not advocating "no parallelism", rather we advocate that any state should be modified by a single thread, to avoid contention. Our measurements have shown that the cost of contention almost always outweighs the benefit. So avoid contention, not parallelism.

  Dave Farley 
  (Head of Software development at LMAX)

Re: The LMAX Architecture - 100K TPS at Less than 1ms Latency

#56
post #30
post #28

I didn't see a place to add comments on his article page. In general, this reminds me a lot of architectures designed for embedded systems today (which are how software was designed for PC's in the early days). The huge up side is performance the huge down side is that it completely ignores the significance of what a relational database offers to the company as a whole. We need to be looking at ways to make SQL datab…

Embedded systems are designed to squeeze the absolute maximum out of the hardware upon which they run. All this processor affinity, cache stride calculation, and avoidance of cross-core conflicts is just how business is done. The upside is performance, because that's what is considered important in this case. The downside, which you've neglected to mention is difficulty of maintenance due to decreased comprehensibili…

I agree with your comments about picking the right tools for the job, but it is my contention that our code, at LMAX, is cleaner as a result of our architecture, not more obscure.

The code that matters to our business, the business logic processors in our services, is a clean, well modelled [ mostly ;-) ] implementation of our domain problem with NO technology constraints - no DB code, no magic annotations, no complex threading code, just single-threaded stateful POJOs that provide the solutions to our business problems. For me that is one of the most important benefits of our approach, not just the significant performance benefits that we get as a result, but the simplicity of the programming model.

We have entirely isolated the complex bits to infrastructure, most of our day to day work is in writing business logic code. High performance code is surely focussed on doing the minimum amount of work for the maximum function. How better to achieve that than have a software simulation of the business problem, a domain model in the DDD sense? Yes you need to pick your collections wisely to represent the relationships within your domain model, but other than that modelling the problem well is a key attribute of both high-performance systems and good code - at least to my way of thinking.

   Dave Farley

Re: The LMAX Architecture - 100K TPS at Less than 1ms Latency

#57
post #50

it seems to me that you need something else that i didn't see described in the article (perhaps i missed it?): the output disruptor has to be able to recognise and discard duplicate requests for output. otherwise, when you replay the input to a new logic processor (after the old one died) you're going to get repeat outputs. is that right or have i misunderstood something else? it seems like it places additional const…

The business logic simply outputs state changes that other systems subscribe to. If the subscribing system misses the update our reliable message delivery will ensure the message gets to the subscribing system and processed. Our system guarantees message processing and not just delivery. Queries against the business domain model are just input events. The business logic will serialise the requested part of the model…

Thanks. In retrospect this seems like the only way you can guarantee eventual consistency anyway, so I suppose I should have assumed it.
Post reply on HN