Search code examples
.nethardwaredesign-patternsfailoverhigh-load

Patterns and technologies for a system capable of processing 40,000 messages per second


We need to build a system capable of processing 40,000 messages per second. No messages can be lost in case of any software or hardware failures.

Each message size is about 2-4Kb.

Processing of a message consists of validating the message, doing some simple arithmetical calculations, saving result to database and (sometimes) sending notifications to other systems.

Preferable software technology is .Net.

What software and hardware patterns are the most suitable for such task?

How much hardware will it require?


Solution

    1. Message queuing. Your process flow sounds like a prime target for it.
    2. Clustering / load balancing.
    3. Streamline your code

    First thing I'd do is queue the notifications. Then I'd queue all database writes that don't need to return a value. Then I'd look at scaling out.

    Other considerations: * Avoid a big clunky framework that does way more work behind than scenes than you likely need. * Make use of cache and static variables wherever possible.

    40,000 messages per second is doable, but when you add IO to the mix, it can be unpredictable even on super fast hardware with a ton of memory. Try to do as much out of band processing as you can. Where that fails, see if you can run multiple threads (on a multi-core or multi-proc machine) and look into multiple servers in a cluster if need be.

    Edit:

    I can't stress enough the benefits of load testing in a scenario like this. Make a simple prototype and load test. Refine the prototype until you get desired results. Then architect a final solution based on the prototype. Until you test for the desired performance level, you're guessing at the solution.