Live data from Hacker News

Kafka is Fast – I'll use Postgres

topicpartition.io

401–410 of 412 posts

Re: Kafka is Fast – I'll use Postgres

#401
>There is also a general expectation that there is strict order - events should be read in the same order that they arrived in the system.

This is the Achilles' heel of Kafka (and Pulsar) where for all streaming systems (or workarounds) with per message key acknowledgements incur O(n^2) costs in either computation, bandwidth, or storage per n messages [1].

[1] What If We Could Rebuild Kafka from Scratch?: (Top comment of the 220 comments)

https://news.ycombinator.com/item?id=43790420

Re: Kafka is Fast – I'll use Postgres

#402
post #391

Earlier quoted context omitted.

> It's trivial to ensure that only one message is delivered to only one consumer if that's what you want. Consumer groups track their offset and then commit the offset, the message stays in Kafka but it won't be read again. This IMO is better behaviour than RabbitMQ The trivial solution is to use Kafka. They're clearly saying that Kafka makes it trivial, not that it's trivial to solve from scratch.

What the parent poster described isn’t what makes Kafka’s “exactly once” semantics work. It’s the use of an idempotency token associated with each publication, which effectively turns “at-least-once” semantics into effectively “exactly once” via deduplication.

We used Flink and S3 compatible backends (for the Flink state) to ensure exactly once processing.

I didn't say Kafka magically solves these problems for you, but it was required for the scalability we needed.

Re: Kafka is Fast – I'll use Postgres

#403
post #292

Earlier quoted context omitted.

The statement is untrue. For example, ClickHouse is in C++, and it has thousands of contributors with hundreds of external contributors every month.

I think it's reasonably common for accepting external contributions to an open-source project to be more trouble than it's worth, just because most programmers aren't very good.

I often use a different approach - assume by default that external contributors are smarter than our employees. This is needed to prevent arrogance and entitlement during code reviews. A reasonable pull request from an external contributor is more valuable than one from an employee.

Re: Kafka is Fast – I'll use Postgres

#404
post #386

Earlier quoted context omitted.

Don't you always need a database after reading events from Kafka to deduplication? So the competing solutions are: PostgreSQL or Kafka+PostgreSQL Kafka does provide some extrs there, handling load spikes, more clients that PG can handle natively and resilience to some DB downtime. But is it worth the complexity, in most cases no.

Actually you can avoid having a separate DB! You can build a materialized view of the data using [KTables]( https://developer.confluent.io/courses/kafka-streams/ktable/ ) or use [interactive queries]( https://developer.confluent.io/courses/kafka-streams/interac... ). The "table" is built up from a backing kafka topic so you don't need maintain another datastore if the data view you want is entirely derived from one o…

My understanding is this is pretty niche and can be complex.

Re: Kafka is Fast – I'll use Postgres

#405

My general opinion, off the cuff, from having worked at both small (hundreds of events per hour) and large (trillions of events per hour) scales for these sorts of problems: 1. Do you really need a queue? (Alternative: periodic polling of a DB) 2. What's your event volume and can it fit on one node for the foreseeable future, or even serverless compute (if not too expensive)? (Alternative: lightweight single-process…

> Do you really need a queue? (Alternative: periodic polling of a DB) In my experience it’s not the reads, but the writes that are hard to scale up. Reading is cheap and can be sometimes done off a replica. Writing to a PostgreSQL at high sustained rate requires careful tuning and designs. A stream of UPDATEs can be very painful, INSERTs aren’t cheap, and even a batched COPY blocks can be tricky.

The key question here is what is "high sustained rate" in numbers?

Re: Kafka is Fast – I'll use Postgres

#406

Earlier quoted context omitted.

I agree with nearly everything except your point (1). Periodic polling is awkward on both sides: you add arbitrary latency _and_ increase database load proportional to the number of interested clients. Events, and ideally coalesced events, serve the same purpose as interrupts in a uniprocess (versus distributed) system, even if you don't want a proper queue. This at least lets you know _when_ to poll and lets you set…

From a database load perspective, Postgres can get you pretty far. The reads triggered by each poll should be trivial index-only scans served right out of RAM. Even a modest Postgres instance should be able to handle thousands per second. The limiting factor for most workloads will probably be the number of connections, and the read/write mix. When you get into hundreds or thousands of pollers and writing many things…

+1 on connections being the limiting factor. Curious how further a connection pooler can get you

Re: Kafka is Fast – I'll use Postgres

#407

You have to be careful with the approach of using Postgres for everything. The way it locks tables and rows and the serialization levels it guarantees are not immediately obvious to a lot of folks and can become a serious bottle-neck for performance-sensitive workloads. I've been a happy Postgres user for several decades. Postgres can do a lot! But like anything, don't rely on maxims to do your engineering for you.

Yes, performance can be a big issue with postgres. And vertical scaling can really put a damper on things when you have a major traffic hit. Using it for kafka is misunderstanding the one of the great uses of kafka which is to help deal with traffic bursts. All of a sudden your postgres server is overwhelmed and the kafka server would be fine.

Agree but we really have to put a number on baseline traffic and max traffic burst in order to be productive in the discussion. I would argue that the majority of use cases never need to be designed for a max-traffic-number that PG can't handle

Re: Kafka is Fast – I'll use Postgres

#408
post #181
post #54

Earlier quoted context omitted.

When someone says just use Postgres, are they using the same instance for their data as well for the queue?

You would typically want to use the same database instance for your queue as long as you can get away with it because then transaction handling is trivial. As soon as you move the queue somewhere else you need to carefully think about how you'll deal with transactionality.

I believe most setups using DB+{Queue,Kafka} don't truly deal with it fwiw.

Re: Kafka is Fast – I'll use Postgres

#409

Earlier quoted context omitted.

To the issue of complexity, is Redpanda suitable as a "single node implementation" where a Kafka cluster is not needed due to data volume, but the Kafka message bus pattern is desired? AKA "Medium Data" ?

Yes. I’ve run projects where it was used that way. It also scales to very large clusters.

Can you give some examples? I'm super curious about single-node Kafka use cases in general

Re: Kafka is Fast – I'll use Postgres

#410

Earlier quoted context omitted.

There is a finite and relatively narrow range of ratios of CPU, memory, and network throughput in both modern cloud offerings and bare hardware configurations. Obviously it's possible to build, for example, a machine with 2 cores, a 10Gbps network link, and a single HDD that would falsify my statement.

But the workload matters. Even the comment in the article doesn't completely make sense for me in that way -- if your workload is 50 operations per byte transferred versus 5000 operations per byte transferred, there is a considerable difference in hardware requirements.

Exactly. "a properly-configured Kafka cluster" implies you have very properly configured your clients too, which is almost never the case because it's practically very hard to do in the messy reality of a large-scale organization.

Even if you somehow get everyone to follow best-practices, you most likely still won't get to saturate the network on "minimal hardware". The number of client connections and requests per second will likely saturate your "minimal CPU".

It's true that minimal hardware on Kafka can saturate the network, but this mostly happens in low-digit client scenarios. In practice, orgs pushing serious data have serious client counts.

Post reply on HN