Code Poetry
and Text Adventures

by catid posted (>30 days ago) 6:42pm Fri. Jul 13th 2012 PDT
I've been looking at ZMQ again recently for something at work and decided against using it, but the investigation got me thinking about ZMQ and where it fits into various applications.

ZMQ has a few different usage patterns that it is optimized for: Router, Dealer, and Pub-Sub.  The router will act as a server and accept data from clients.  The dealer will push data out to a set of end-points in a round-robin fashion (for dealing out work to do for example).  And pub-sub is used for event handling.  The router is the closest thing to a traditional client-server model.

To introduce my perspective, I'm interested in real-time systems like online games, where low-latency is the goal, and bandwidth is not usually a limitation.  Furthermore, the servers should not be operating anywhere near their full capacity to avoid latency spikes.


Why ZMQ is exactly the opposite of what is needed for a real-time online game

ZMQ is basically a progression of the standard TCP socket taken to a logical "next step".  Things that work well over TCP sockets tend to work great in ZMQ.  However, real-time online games are never ideally written using TCP sockets.  And ZMQ is another step in the wrong direction away from UDP.

It's clear that multiple types of ZMQ sockets are needed to handle all of the things going on in a game.  Publishers and subscribers for different events that are distributed geographically based on how close players are to each other, etc.  If you think about all of the messaging types in an online game, ZMQ starts becoming inadequate even for the non-real-time messages.

As another example, player position updates may be sent periodically and unreliably (over UDP), and only the latest (timestamped) message is used.  ZMQ has no facility for this: All messages will be received and in order.

I don't hate ZMQ.  I think it's an amazingly good project in that it abstracts away the painful parts of async networking io, including platform-specific lockless algorithms, operating system APIs, and so on.


Still searching for the low-latency brother of ZMQ

I'm still looking for the library that captures all the low-hanging fruit of async io and rolls it into a good transport layer for real-time online games, streaming video, and so on.  All of the ones I know of are commercial...  Will keep searching.