Live data from Hacker News

Streaming: a skill gap?

charemza.name

21–30 of 39 posts

Re: Streaming: a skill gap?

#21

I recently rewrote some streaming code to slurping. While there are theoretical advantages to streaming, unless you really really need them the drawbacks are not worth it. My comment in the code was "Streaming is hard, memory is cheap."

Memory can be relatively cheap (at least up to the 1TB point), but you still need to account for hard software development problems - such as populating that large blob of data into memory from across the network, in a fault tolerant fashion.

Re: Streaming: a skill gap?

#22

I've run into plenty of situations where a streaming approach would be faster. The complexity of it always necessitates making a slower conventional version. (wait for all the data to load into memory and the operate on it) the conventional approach is easier to debug and get working. 90% of the time, the gains from streaming aren't worth the added effort. Generally you only really get value for it when you're proces…

Most programming languages support generator semantics, letting you do development monolithically while still allowing for easy refactoring into streaming components. You simply have to include the goal of using generator semantics into the design up front.

Re: Streaming: a skill gap?

#23

The issue is that the structures to handle streaming are not often first class (in languages other than Go, Rust, and JavaScript). And when they are, the the third party interfaces are not. Eventually your data will have to reach the DB and it would bottleneck. Nobody wants to use KV storage all the time, SQL systems and ORMs need to step up their concurrency game.

SQL systems on pretty boring hardware are capable of millions of transactions per second. The schema must simply be designed with concurrent modifications in mind (less mutation and long lived transactions).

Re: Streaming: a skill gap?

#25
As the author alludes to at the end, streaming is a skill, and I think that really is a big issue. A lot of us, myself included, don't immediately reach for streaming as a solution to our problems, even if it can be.

For instance, I'm working on a file-based CRDT-style distributed, journaling database (for single-user but multi-device) and the "diffs" for a single device are stored in a journal. Now in retrospect, it's obvious that I don't need to store the entire journal of diffs in memory (this is a "streaming" architecture), but on my first couple of passes, because it was easier, I stored everything in memory.

After playing around with some toy projects using my database, I realized this wouldn't scale (why load all of history into memory if you don't need it?) and not only that my system lends itself better to a "file stream", i.e. don't store everything in mem, just append to existing files or read from them as needed. Seems obvious now, but when building it out, my first inclination wasn't to do it that way.

Re: Streaming: a skill gap?

#27
I'm jaded. It takes one non-streaming detail in the entire system to ruin the whole thing.

Some data formats need writing a length in the header. Or reading requires metadata stored after the data. Some algorithms need two passes, or can be streamed over columns when you're getting rows.

Re: Streaming: a skill gap?

#28
Should be easy enough to code, no? Streams come built-in with Node, and I'm sure other runtimes have similar concepts. Emit data out of the stream when you have some, process data by listening to a stream and doing something when it emits.

Re: Streaming: a skill gap?

#30
The buffer size handling of stream is is handling in nodejs using a mechanism called backpressuring.

https://en.m.wikipedia.org/wiki/Backpressure_routing

And nodejs's site even has a article for it.

https://nodejs.org/es/docs/guides/backpressuring-in-streams/

However, even the nodejs runtime itself already provide mechanism to let you handle backpressuring easily. Most people still don't do and make their program crash when streaming target is stuck for whatever reason.

Post reply on HN