DEV Community

miinhho
miinhho

Posted on • Edited on

Middleware Stream Architecture - with Asyncrush

Hello everyone!

Async data is everywhere these days—chat apps, IoT, real-time dashboards—and I’ve been thinking there’s got to be a better way to handle it.
So, I came up with something I’m calling the Middleware Stream Architecture, and I’ve built it into a little project called Asyncrush.

It’s my first stab at rethinking async streaming to be faster, more flexible, and honestly, just more fun to work with. If this is your first time hearing about it, stick with me—I’ll walk you through what it’s all about and why I think it’s pretty cool.


Streams + Middleware = Magic

The big idea here is dead simple: take a data stream and plug middleware into it to shape it however you want. You know those moments when messages are flying in or sensor data won’t stop coming? Imagine having a tool that lets you tweak that flow on the fly. That’s where middleware comes in.

If you’ve used Express.js, you’re probably familiar with middleware—those handy little functions that tweak requests as they pass through.
I thought, “Why not bring that vibe to async streaming?” With Asyncrush, you can drop middleware into the stream to transform data, pause it, or even split it off to multiple places. It’s like giving your data stream superpowers.


What Makes It Different?

I’ve played with tools like RxJS (and don’t get me wrong, they’re so awesome), but sometimes they feel like overkill—too complex, too heavy. I wanted to fix that. Here’s how I designed this architecture

  • Speedy and Light:
    I cut out the extra fluff to keep things lean. The more data you throw at it, the more you’ll notice how zippy it is compared to the usual suspects.

  • Bend It Your Way:
    Pause it, slow it down, tweak the data—whatever you need, you’re in control. It’s like a stream you can tune like a guitar.

  • Real-World Ready:
    From handling errors to sending data to multiple spots, it’s built for the messy stuff we actually deal with in real apps.


How fast is it?

(1,000,000,000 events vs RxJS)

Transforms ops/sec How much faster
100 4,549,029 +80%
50 8,041,039 +40%
20 27,055,086 +54%
10 43,926,787 +27%
5 85,472,016 +25%
2 167,830,565 +15%

GitHub logo miinhho / Asyncrush

lightweight & fast library for streaming and processing asynchronous events

Asyncrush

High Performance Middleware Streams 🏎️

Asyncrush is a high-performance stream processing library that leverages the middleware pattern inspired by RxJS. Unlike traditional stream libraries, Asyncrush connects middleware using pure functions instead of operators, offering a flexible, efficient, and scalable approach to stream processing. It dramatically improves performance while minimizing memory usage, making it the ideal choice for high-throughput applications.


⚡ Key Features

  • Blazing Fast Performance: Achieves up to 2x faster performance compared to traditional stream libraries.
  • Middleware-based Stream Control: Process streams with middleware instead of operators, allowing for dynamic error handling, custom retry policies, and advanced state management.
  • Memory Efficiency: Minimized object creation and small code size lead to significant reductions in memory consumption.
  • Developer-Friendly API: The pure function-based API ensures that the library is easy to understand, use, and maintain.
  • Built-in Error Handling & Backoff: Automatic error handling and backoff strategies allow for…
  • Update to more extreme situations (2025-03-02)

How Does It Roll?

Picture a river flowing with data—that’s your stream. Now imagine adding some gear to it:

  1. Middleware: Slap a filter on that river to clean up the water or dye it blue—aka process your data.
  2. Flow Control: Build a dam to hold it back or let it trickle out, keeping things from flooding your app.
  3. Splitting It Up: Divvy the river into streams for different towns—one stream feeding multiple endpoints, no sweat.

The best part? It all works together seamlessly. No crazy setup—just plug in and go.


Where It Shines

Here’s where I see it making a difference:

  1. Chat Apps: Messages streaming in fast? Filter out the trolls with middleware and blast it to every user at once.
  2. Big Data Crunching: Need speed without losing control? Asyncrush handles it like a champ.

Why I’m Hyped About It

Building this, I kept thinking, “I don’t want devs to dread async streams.” Some tools make you jump through hoops or study a novel’s worth of docs. Not this. Asyncrush feels like grabbing a handful of Lego blocks—you snap together what you need, and it just works. Fast. Flexible. Ready for real projects.


What’s Next?

This is my first go at it, so it’s still fresh out of the oven. I’d love for you to kick the tires—tell me what you think, where it could level up. Real-time apps are taking over, and I believe this architecture could be a game-changer for async data. Want to build it with me? Let’s chat in the comments!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post