Michael B
Michael B

Reputation: 289

Why reactor pattern (Twisted, Gevent, Node.js, etc.)

From reading this article, http://www.artima.com/articles/io_design_patternsP.html

I understand that the proactor pattern is fully asynchronous while the reactor pattern is not.

All the popular asynchronous event-driven networking frameworks that I'm aware of (Twisted, Gevent, Tornado, Asyncio, and Node.js) apply the reactor design pattern. Why is that? Doesn't the proactor pattern provide better performance?

Upvotes: 1

Views: 1360

Answers (1)

user2137858
user2137858

Reputation: 289

Because, as this article you cited points out, a Proactor pattern requires kernel-level (internal) support for asynchronous I/O, and not all OSes provide that natively within their user-facing I/O layer. The frameworks you mention are all multi-platform toolkits/modules, so need to support a wide variety of OS I/O architectures.

Without having to provide platform-specific "backend" implementations for each OS, these frameworks opt for the "lowest common denominator" design pattern. The Reactor pattern is more universal, and is hence can be implemented natively without requiring different backends.

Upvotes: 3

Related Questions