Video in progress

When do you really need Kafka in a project, and when is a plain REST call enough?

Use Kafka when several services need to receive the same event independently, when you need to buffer an event stream, or when you need to replay history. For a plain request-response where you need an answer right away, REST is simpler and the better fit.

📖 Answer

Cases where Kafka fits:

  • The "order created" event is received by the warehouse, notifications and analytics, each at its own pace; the order service doesn't know about them.
  • The incoming flow spikes sharply (a sale day) and the downstream service is slow: Kafka sits in between as a buffer.
  • Audit, event sourcing, CDC: you need to replay history.
  • Collecting logs and metrics.

Cases where REST is better: a user asks "what's my balance?" and is waiting for the answer right now. Doing that through Kafka is extra complexity: two topics, a correlation ID, a timeout.

I once saw a project with 3 services and a few thousand requests a day where they'd put in Kafka just to be "modern". As a result, running the cluster ate a big share of the working time. Kafka isn't free: you have to run it, monitor it and upgrade it.