Assess your understanding of key concepts in reactive and event-driven functional backends, covering asynchronous processing, event handling, and core principles of reactive programming. Perfect for learners seeking foundational insight into scalable backend architectures.
Which feature best characterizes asynchronous processing in a reactive backend when handling thousands of simultaneous requests?
Explanation: Asynchronous processing enables responses to be handled without blocking a thread per request, which is more scalable. Executing requests one by one is synchronous, not asynchronous. Using a separate thread per request can lead to resource exhaustion and is not necessarily asynchronous. Instantaneous responses are unrealistic and not a requirement for asynchronous processing.
In an event-driven backend system, how are components typically notified when something of interest occurs?
Explanation: Event-driven systems use the publish-subscribe pattern to decouple components and allow automatic notification when events happen. Polling consumes unnecessary resources and is less efficient. File transfers are not related to event notification. Synchronous calls require waiting and do not fit the event-driven model.
What is the purpose of back pressure in a reactive system processing a high volume of events?
Explanation: Back pressure provides flow control to avoid overwhelming consumers by notifying producers to adjust the event rate. Increasing event speed can overburden the system. Unlimited memory storage is unsustainable and not a true solution. Instant processing is not practical in real systems and is not the purpose of back pressure.
Why is immutability important in functional programming for event-driven backends?
Explanation: Immutability ensures that once data is set, it cannot be altered, reducing unintended side effects and making behavior predictable—important for concurrency. Changing variables at runtime introduces side effects. Global mutable state is discouraged in functional programming. Higher-order functions are commonly used in functional styles and are not prohibited.
What main problem do reactive streams aim to solve in functional backends?
Explanation: Reactive streams are designed for managing asynchronous data flows and implementing back pressure for resource efficiency. Batch processing is unrelated to the concept of reactive streams. Storing data on disks pertains to storage, not data flow. Limiting to synchronous paths negates the reactive approach.
What is the primary function of an event loop in an event-driven backend system?
Explanation: An event loop manages and processes incoming events, delegating to appropriate handlers for non-blocking execution. Blocking on tasks contradicts event-driven principles. Creating infinite threads is inefficient and can overwhelm resources. Enforcing strict synchrony undermines the benefits of event-driven architecture.
In the context of event-driven functional backends, how are side effects typically managed?
Explanation: Functional approaches aim to control or limit side effects by confining them, often at the boundaries such as input/output, improving testability and reliability. Spreading side effects increases complexity and unpredictability. Relying on mutable global variables can cause bugs. Direct state changes contradict functional principles.
When using the observable pattern in reactive programming, what does an observable represent?
Explanation: An observable represents a stream of data or events, allowing observers to react as new items arrive. A static value lacks dynamic updates. Polling is unnecessary with observables because updates are pushed. One-time timer events are not typically represented as observables unless recurring.
Why might event ordering be significant in reactive and event-driven backends, especially when handling financial transactions?
Explanation: In domains like finance, order determines correctness—incorrect order can result in inconsistent processing. Random order might improve parallelism but not correctness. In some applications, order does matter, so saying it never matters is incorrect. Ignoring ordering for parallelism risks breaking business logic.
Which approach is most suitable for handling errors in asynchronous event-driven streams?
Explanation: Error propagation along the stream with dedicated error handling allows resiliency and continued operation. Terminating the whole system is extreme and reduces system reliability. Ignoring errors can hide important failures. Synchronous error handling alone does not address asynchronous or streaming scenarios.