News for hackers. Stuff that matters.
Re:Pulsar – an open-source distributed pub-sub messaging pla... by gas9S9zw3P9c on Monday July 13, 2020 @06:02AM (#23819050)
I've used Kafka a lot in the past and I've been looking at Pulsar. The broker being stateless is great. I've had issues with moving partitions around in Kafka.

That being said, I'm getting tired of managing these clunky memory-hungry JVM-based systems that rely on external dependencies like Apache Zookeeper and BookKeeper. They may be necessary if you're Yahoo, but I would argue that for the vast majority of companies, these complex systems create so many administration headaches that the net productivity impact is negative. I've spend days or weeks debugging Kafka issues. I almost feel like "big clunky heavy JVM enterprise software" has become synonymous with Apache projects.

If you don't absolutely need the messaging guarantees I would recommend looking into NATS (https://nats.io/) - it's a brokered systems that's significantly more lightweight and super easy to deploy and play around with. You can get persistence and delivery guarantees with NATS streaming, but that part is optional and a bit more early stage.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by miguno on Monday July 13, 2020 @06:45AM (#23819295)
> The broker being stateless is great. I've had issues with moving partitions around in Kafka.

Well, the Pulsar broker is (kinda) stateless, because they are essentially a caching layer in front of BookKeeper. But where's your data actually stored then? In BookKeeper bookies, which are stateful. Killing and replacing/restarting a Bookkeeper node requires the same redistribution of data as required in Kafka’s case. (Additionally, BookKeeper needs a separate data recovery daemon to be run and operated, https://bookkeeper.apache.org/archives/docs/r4.4.0/bookieRec...)

So the comparison of 'Pulsar broker' vs. 'Kafka broker' is very misleading because, despite identical names, the respective brokers provide very different functionality. It's an apples-to-oranges comparison, like if you'd compare memcached (Pulsar broker) vs. Postgres (Kafka broker).

Re:Pulsar – an open-source distributed pub-sub messaging pla... by ckdarby on Monday July 13, 2020 @09:45AM (#23820662)
Brokers in Pulsar can be seamlessly added or removed.

Bookies can seamlessly be added.

Kafka unless there has been a KIP since I stopped paying attention to Kafka doesn't do this.

I remember adding brokers to Kafka and taking advantage of them on existing topics meant repartitioning which if I recall correctly breaks the golden ordering contract that most devs bank on. The data written to the partition will always be in the order for that partition itself.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by miguno on Monday July 13, 2020 @11:19AM (#23821673)
> Bookies can seamlessly be added.

Kafka brokers can seamlessly be added, too.

> I remember adding brokers to Kafka and taking advantage of them on existing topics meant repartitioning which if I recall correctly breaks the golden ordering contract that most devs bank on.

Adding brokers to Kafka does not require repartitioning. It requires data rebalancing ('migrate' some data to the new brokers), which does not break any ordering contract. I suppose the words sound sufficiently similar that they are easy to be mixed up. :)

(For what it's worth, BookKeeper requires the same data rebalancing process.)

> The data written to the partition will always be in the order for that partition itself.

Yes, for Kafka, all log segments that make up a topic-partition are always stored -- or, when rebalancing, moved -- in unison on the same broker. Or, brokers (plural) when we factor in replication. Kafka's approach has downsides but also upsides: data is always stored in a contiguous manner, and can thus also be read by consumers in a contiguous manner, which is very fast.

In comparison, BookKeeper has segmented storage, too. But here the segments -- called ledgers -- of the same topic-partition are spread across different BK bookies. Also, because of how BookKeeper's protocol works (https://bookkeeper.apache.org/docs/4.10.0/development/protoc...), what bookies store are actually not contiguous 'ledgers', but in fact 'fragments of ledgers' (see link). As mentioned elsewhere in this discussion, one downside of this approach is that BK suffers proverbially from data fragmentation. (Remember Windows 95 disk fragmentation? Quite similar.)

No approach is universally better than the other one. As often, design decisions were made to achieve different trade-offs.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by ckdarby on Monday July 13, 2020 @07:31PM (#23826870)
Maybe we're both mixed up.

Let's say we have a cluster with a sort of "global" topic called "incoming-events" and it has 10 partitions.

We'll most likely eventually end up with a "hot" write partition because rarely do I see a perfect even distribution in event streams.

I'd like to seamlessly add capacity to remove this hot spot.

With Pulsar you're using BK which means just spinning up more bookies which will take on new segments and then the rebalancement will move some segments off.

With Kafka I don't know what the option is aside from spinning up a larger and larger broker & rebalancing to the larger box. What I typically see in companies are they repartition from 10 to 20 to avoid expensive one off boxes.

Nobody likes non-uniform resources because it is a nightmare to manage. Imagine a k8s deployment where you have replica:10 but have to handle a custom edge case for resource allocation on one pod different than the other 9 brokers.

(Just assumed 10 partitions to 10 pods)

Re:Pulsar – an open-source distributed pub-sub messaging pla... by miguno on Tuesday July 14, 2020 @02:51AM (#23829245)
Both Kafka and Pulsar have this kind of bottleneck in your scenario -- say, one "hot" write partition.

If one Kafka broker or BookKeeper bookie node cannot keep up with the write load (e.g. network or disk too slow, CPU util too high), you must add more partitions. For Kafka, for the reasons you already mentioned. For BookKeeper (and Pulsar), because only a single ledger of a topic-partition is open for writes at any given time.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by matteomerli on Monday July 13, 2020 @01:29PM (#23823249)
> Kafka brokers can seamlessly be added, too.

You can add as man as you want, but they take no traffic.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by enitihas on Monday July 13, 2020 @10:32AM (#23821145)
How do bookkeeper nodes handle addition then. AFAIK, if you add new storage nodes, whether bookkeeper or Kafka, there has to be some repartitioning, or else how will the new node be useful at all?
Re:Pulsar – an open-source distributed pub-sub messaging pla... by miguno on Monday July 13, 2020 @11:28AM (#23821776)
See my previous answer further up in this sub-thread. Neither Kafka nor BookKeeper require data repartitioning when adding new nodes. Instead, both require data rebalancing, which moves some data from existing nodes to the newly added nodes.

Think: repartitioning changes the logical layout of the data, which can impact app semantics depending on your application; whereas data (re)balancing just shuffles around stored bytes "as is" behind the scenes, without changing the data itself. The confusion stems probably from the two words sounding very similar.

For Kafka, you use tools like Confluent's Auto Data Balancer (https://docs.confluent.io/current/kafka/rebalancer/index.htm...) or LinkedIn's Cruise Control (https://github.com/linkedin/cruise-control) that automatically rebalance the data in your Kafka cluster in the background. Pulsar has its own toolset to achieve the same.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by sciurus on Monday July 13, 2020 @11:06AM (#23821514)
https://jack-vanlightly.com/blog/2018/10/2/understanding-how... goes into this.

> The data of a given topic is spread across multiple Bookies. The topic has been split into Ledgers and the Ledgers into Fragments and with striping, into calculatable subsets of fragment ensembles. When you need to grow your cluster, just add more Bookies and they’ll start getting written to when new fragments are created. No more Kafka-style rebalancing required. However, reads and writes now have to jump around a bit between Bookies.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by jackvanlightly on Monday July 13, 2020 @01:09PM (#23823026)
If consumers are keeping up, there will be no reads to the BookKeeper layer as the Pulsar broker will serve from memory.

When reads need to go to BookKeeper there are caches there too, with read-aheads to populate the cache to avoid going back to disk regularly.

Even when having to go to disk, there are further optimizations in how data is laid out on disk to ensure as much sequential reading as possible.

Also note that the fragments aren't necessarily that small either.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by enitihas on Monday July 13, 2020 @11:10AM (#23821558)
Ok so it will sacrifice some throughout when a new node is added, as reads and writes need to jump a bit.
Re:Pulsar – an open-source distributed pub-sub messaging pla... by heipei on Monday July 13, 2020 @09:37AM (#23820576)
Depending on your application architecture I'd look into nsq (https://nsq.io/) which works quite differently from most message brokers in that you're supposed to run one instance of the broker per server so you always have one local instance that you can publish to, no matter the current network conditions.
Re:Pulsar – an open-source distributed pub-sub messaging pla... by httgp on Monday July 13, 2020 @09:21AM (#23820430)
There’s also Liftbridge (https://liftbridge.io/) which is built to offer Kafka-like features on top of NATS. It just hit v1.0 and looks super promising.

Full disclaimer: I worked on building a client library for it while it was in its early stages, and from my limited time with it, it was super easy to operate, very light on resource usage and stupid-fast.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by didip on Monday July 13, 2020 @12:12PM (#23822358)
Is liftbridge open source?
Re:Pulsar – an open-source distributed pub-sub messaging pla... by KptMarchewa on Monday July 13, 2020 @06:13AM (#23819109)
>That being said, I'm getting tired of managing these clunky memory-hungry JVM-based systems that rely on external dependencies like Apache Zookeeper and BookKeeper.

One of my pet peeves with Kafka were CLI tools written in JVM languages. Slow JVM startup time was killing my focus.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by q3k on Monday July 13, 2020 @06:23AM (#23819163)
> ... systems that rely on external dependencies like Apache Zookeeper and BookKeeper.

I would argue that building up on existing systems (especially things like a distributed consensus system like Zookeeper) is generally good practice. Being able to just point a bunch of self-contained JARs/WARs at a Zookeeper/etcd cluster and not worry about startup sequencing or cluster bootstrapping makes me happy.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by imglorp on Monday July 13, 2020 @06:37AM (#23819253)
Hasn't Kafka been talking about eliminating external zk forever? Are they making it an internal library or adopting a new consensus scheme?
Re:Pulsar – an open-source distributed pub-sub messaging pla... by miguno on Monday July 13, 2020 @07:07AM (#23819427)
Yes, you remember correctly. The Kafka community has already started the work on getting rid of ZooKeeper. See https://cwiki.apache.org/confluence/display/KAFKA/KIP-500%3A... for details.
Re:Pulsar – an open-source distributed pub-sub messaging pla... by FridgeSeal on Monday July 13, 2020 @07:14AM (#23819486)
From my understanding, they’re going to use the brokers as their own metadata store, so the data that was in ZK goes in a topic instead, and I believe Raft for leadership?

KIP-500 is the proposal/PR (?) for ZK-free Kafka which I understand has been merged in and work is now progressing on follow up tasks.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by vips7L on Monday July 13, 2020 @12:20PM (#23822465)
Modern JVMs don't take that long to start. While not at raw binary levels they shouldn't be killing your focus as theyre on par with scripting languages.

https://cl4es.github.io/2019/11/20/OpenJDK-Startup-Update.ht....

Re:Pulsar – an open-source distributed pub-sub messaging pla... by KMag on Monday July 13, 2020 @10:15PM (#23827832)
That depends on the filesystem, memory pressure, etc. Most JVM-based apps have quite a bit of filesystem I/O at startup, and a surprising memory footprint. If the kernel's page cache is mostly full of dirty pages, that's a bunch of extra disk writes in order to free up RAM for the JVM.

These startup benchmarks are typically not run with the JVM and application jars being pulled from NFS or AFS on a machine with a lot of dirty pages in the page cache. Some small sh/bash app using curl or wget to hit a REST API is going to have a lot less network and disk I/O in that case, even if bash and curl are being pulled from NFS/AFS. Many companies run JVMs from NFS/AFS to simplify deployment and management.

Also, if the OP is logged into a server running the JVM-based CLI app, they may be running it on a server JVM and getting much more eager JITting.

Maybe it's not fair to the JVM that there are lots of circumstances where things are accidentally tuned poorly for the JVM. On the other hand, there is a lot to be said for tiny apps that are pretty resilient to poor conditions. Sometimes size still matters, even on big servers with plenty of RAM and cores.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by gas9S9zw3P9c on Monday July 13, 2020 @06:19AM (#23819142)
Yep. I'm using containers and Kubernetes in production so I'm trying to stay far away from anything JVM-based. On top of being slow to start, memory hungry, and plagued by GC issues, JVM docker images are always huge. I don't want two layers of virtualization. If Docker and k8s become more mainstream that's probably bad news for a lot of JVM projects. Of course, Pulsar itself is quite old (2013?) so it was built well before any of the containerization stuff took off.
Re:Pulsar – an open-source distributed pub-sub messaging pla... by zumachase on Monday July 13, 2020 @06:39AM (#23819261)
I’m not really sure what containers/k8s has to do with JVM? Containers are just name spacing, not virtualization. If you’re running in the cloud, either way you slice it you’ll have two virtual machines: hypervisor and JVM.

I’d argue that being able to herd your JVM procs like cattle makes them good candidates for k8s because you can always just set resource limits so they get purged when the heap becomes too large.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by ckdarby on Monday July 13, 2020 @09:48AM (#23820695)
I don't understand the relationship between containers, kubernetes and JVM.

I run a prod Pulsar cluster using helm charts. All containers & kubernetes, zero issue.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by maxdo on Monday July 13, 2020 @08:46AM (#23820158)
You Probably just heard something about kubernetes and never really used it. Pulsar has its own helm chart. Installation in this cause is as trivial as any other product. It might require 1-2 gb of memory more but is it really critical ?

Nats itself is never stable product , which is been completely rewritten several times. If you want same level or functionality is not on pair or you have to use another rewrite of it in deep alpha. Just try to do a basis negative acknowledgment on NATS :) it’s not there

What I like about Nats it’s their dev focused approach. Clients are shining.

Pulsar instead doesn’t have a decent support of nodejs

Re:Pulsar – an open-source distributed pub-sub messaging pla... by molszanski on Monday July 13, 2020 @09:08AM (#23820341)
+1 for nats.

It is amazing how quickly it went from "what is nats" to "that feature that required a message broker is complete".

Good job nats team.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by RedShift1 on Monday July 13, 2020 @09:41AM (#23820614)
No love for MQTT as message bus in this space?
Re:Pulsar – an open-source distributed pub-sub messaging pla... by site-packages1 on Monday July 13, 2020 @10:34AM (#23821165)
Seconding this comment, I've had nothing but complexity added for not much benefit in this space by needing to _also_ manage Zookeeper. Would love something small/stateless that isn't necessarily "Yahoo Production Grade" and can service hundreds or thousands of requests per second.

Will check out NATS.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by dehrmann on Monday July 13, 2020 @12:26PM (#23822550)
It sounds like you're gripe isn't actually with Java or even the memory footprint, is that's you don't want to manage Zookeeper in addition to managing Kafka.
Re:Pulsar – an open-source distributed pub-sub messaging pla... by gas9S9zw3P9c on Monday July 13, 2020 @02:27PM (#23823924)
Yeah, more or less. I'm not complaining about the JVM directly, but rather about what typical Java software, of which Kafka is one example, looks like, at least in my mind. Whenever I see JVM I think: Horrible user experience and tooling, bad memory footprint, slow to start and deploy, complex codebase where it's impossible to debug issues, huge Docker images, complicated configuration and tuning options that doesn't work out of the box, dependency hell, and so on. It's the typical enterprise package for managers that don't want to get fired - Nobody got ever fired for buying IBM.

When I see something like NATS - A few thousand lines of code and a 40MB image, that makes me happy. It's a lightweight thing that "just works."

That's why I stay away from anything JVM. And I acknowledge that I am totally biased and may be wrong in some cases, but that has been my experience.

Re:Pulsar – an open-source distributed pub-sub messaging pla... by iampims on Monday July 13, 2020 @01:13PM (#23823073)
For a drop-in Kafka replacement, check out: https://vectorized.io/redpanda/
Re:Pulsar – an open-source distributed pub-sub messaging pla... by kh_hk on Monday July 13, 2020 @06:55AM (#23819363)
I found redis pub/sub to fit most of the needs for a lightweight message passing system, if you do not need persistence.
Re:Pulsar – an open-source distributed pub-sub messaging pla... by lulf on Monday July 13, 2020 @08:10AM (#23819868)
I’ll throw in another alternative to look at for those using Kubernetes: https://enmasse.io