High-Speed Subscribers (Black Box Pattern)
Now letâs look at one way to make our subscribers faster. A common use case for pub-sub is distributing large data streams, like market data coming from stock exchanges. A typical setup would have a publisher connected to a stock exchange, taking price quotes and sending them out to a number of subscribers. If there were only a handful of subscribers, we could use TCP. With a larger number of subscribers, weâd probably use reliable multicast, i.e., PGM.
Letâs imagine our feed has an average of 100,000 100-byte messages a second. Thatâs a typical rate, after filtering market data we donât need to send on to subscribers. Now we decide to record a dayâs data (maybe 250 GB in 8 hours), and then replay it to a simulation network (i.e., a small group of subscribers). While 100K messages a second is easy for a ÃMQ application, we want to replay it much faster.
So we set up our architecture with a bunch of boxesâone for the publisher and one for each subscriber. These are well-specified boxesâ8 cores, 12 for the publisher.
And as we pump data into our subscribers, we notice two things:
When we do even the slightest amount of work with a message, it slows down our subscribers to the point where they canât catch up with the publisher again.
Weâre hitting a ceiling, at both the publisher and the subscribers, of around 6M messages a second, even after careful optimization and TCP tuning.
The first thing we have to do is break our subscriber ...
Get ZeroMQ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.