Junior — Middle
Explain the difference between hot and cold data streams in reactive systems.
sobes.tech AI
Answer from AI
In reactive systems, data streams are of two types: hot and cold.
-
Cold streams are streams that start generating data only after a consumer subscribes. Each subscriber receives the full data stream from the beginning.
-
Hot streams are streams that generate data regardless of whether there are subscribers. A subscriber receives data starting from the moment of subscription and misses previous events.
Example:
- Cold stream — reading a file: data is read anew for each subscriber.
- Hot stream — sensor events: data is continuously emitted, and the subscriber only receives the current values.
This distinction is important to consider when designing reactive systems to properly manage the timing and volume of data received by the consumer.