Event Driven Architecture Flashcards

1
Q

What is Event-Driven Architecture (EDA)?

A

Answer: EDA is a system design pattern where services communicate by producing and consuming events, allowing for loose coupling, scalability, and asynchronous communication between components.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

When is Event-Driven Architecture a good fit in a Ruby on Rails application?

A

EDA is useful when you have multiple independent services that need to react to changes or events (e.g., user registration, order creation) without being tightly coupled, and when asynchronous processing is required.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a message broker, and how is it used in event-driven architecture?

A

A message broker is middleware (like Kafka or RabbitMQ) that routes messages (events) between producers and consumers, ensuring decoupling of services and allowing for asynchronous processing of events.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s the difference between Kafka and RabbitMQ?

A

Kafka: Best for high-throughput, distributed event streaming with strong support for real-time processing.

RabbitMQ: Best for reliable message delivery and more traditional message queuing with complex routing logic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is asynchronous communication important in a Ruby on Rails application?

A

Asynchronous communication allows tasks (e.g., sending emails, processing large data) to be handled in the background without blocking the main application thread, improving performance and scalability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do message brokers decouple services in a Ruby on Rails app?

A

Message brokers decouple services by allowing them to communicate through events rather than direct calls, so each service operates independently, improving fault tolerance and scalability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When should Kafka be used in a Ruby on Rails app?

A

Kafka is ideal when you need to handle a large volume of events, require real-time data streaming, or need durable, highly distributed systems that process events in order (e.g., analytics, logs, monitoring).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When should RabbitMQ be used in a Ruby on Rails app?

A

RabbitMQ is better when you need complex message routing, guaranteed message delivery, or need to process tasks in the background (e.g., job queues, user notifications).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are producers and consumers in event-driven systems?

A

Producers: Services that emit events (e.g., a Rails app that creates a new user).

Consumers: Services that listen for and process those events (e.g., a background worker that sends a welcome email).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How are events handled in a Ruby on Rails app?

A

Rails applications can use gems like sneakers or racecar to handle message brokers (RabbitMQ or Kafka) for processing events in background jobs (using Sidekiq, Resque, etc.).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do message brokers ensure reliability and scalability?

A

Message brokers like Kafka and RabbitMQ provide durable message storage, fault tolerance, and horizontal scalability, allowing your Rails app to process high volumes of events reliably.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is eventual consistency in the context of EDA?

A

Eventual consistency means that, in an event-driven system, different services might not immediately reflect changes, but will eventually be consistent as events are processed asynchronously.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between message queueing and event streaming?

A

Queueing (RabbitMQ): Messages are sent and processed once by consumers in a traditional queue.

Streaming (Kafka): Events are stored in a log and can be consumed by multiple consumers, allowing for real-time data processing and replayability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can a Ruby on Rails app act as an event producer?

A

A Rails app can produce events by publishing messages to a message broker (e.g., RabbitMQ or Kafka) whenever key actions occur, like user signups or purchases.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can a Ruby on Rails app consume events?

A

A Rails app can consume events by subscribing to a message broker and processing events asynchronously using background jobs or services (e.g., sending notifications, updating databases).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does Sidekiq integrate with RabbitMQ in a Rails app?

A

Sidekiq can be used with RabbitMQ as a job queue to process background tasks asynchronously. Sidekiq workers can consume messages from RabbitMQ and handle events (e.g., sending emails, processing data).

16
Q

How does Kafka help scale a Rails app?

A

Kafka allows a Rails app to handle large volumes of real-time events across distributed systems. It helps scale by decoupling services, ensuring events are processed independently and asynchronously.

17
Q

How is error handling managed in event-driven Rails apps?

A

Errors in event-driven systems are managed through retry mechanisms, dead-letter queues (for unprocessable events), and monitoring tools like Prometheus or Grafana to track failed events and issues.

18
Q

What’s the difference between “at-least-once” and “at-most-once” delivery in message brokers?

A

At-least-once: Guarantees that messages are delivered at least once, even if duplicates occur.

At-most-once: Guarantees that messages are delivered at most once, avoiding duplicates but risking message loss.

19
Q

What are the benefits of using event-driven architecture in Ruby on Rails?

A
  • Loose coupling: Services operate independently, reducing dependencies.
  • Scalability: Each service can scale independently based on demand.
  • Resilience: The system continues to function even if some services fail.
  • Flexibility: Easy to add new features and services without affecting existing ones.