Performance Impacts in Reactive Programming

  1. Blocking I/O: Avoid using blocking I/O calls like FileInputStream, InputStreamReader, or OutputStreamWriter in a reactive application, since these can block the event loop and reduce performance. Instead, use non-blocking I/O libraries like java.nio or reactive libraries like Project Reactor to perform I/O operations.
  2. Heavy computation: Avoid performing heavy computation inside the reactive chain, since this can block the event loop and reduce performance. Instead, offload heavy computation to a separate thread pool using operators like subscribeOn().
  3. Thread.sleep(): Avoid using Thread.sleep() in a reactive application, since this can block the event loop and reduce performance. Instead, use operators like delayElements() or interval() to introduce delays.
  4. Synchronous JDBC calls: Avoid using synchronous JDBC calls in a reactive application, since these can block the event loop and reduce performance. Instead, use a reactive database driver or offload database calls to a separate thread pool using operators like subscribeOn().
  5. Synchronous HTTP clients: Avoid using synchronous HTTP clients like HttpClient or RestTemplate in a reactive application, since these can block the event loop and reduce performance. Instead, use reactive HTTP clients like WebClient.
  6. Excessive logging: Avoid excessive logging in a reactive application, since this can add overhead and reduce performance. Instead, use appropriate logging levels and limit the amount of data logged.
  7. Large payloads: Avoid processing large payloads in a reactive application, since this can consume large amounts of memory and reduce performance. Instead, use streaming to process large payloads in smaller chunks.
  8. Excessive use of filters: Avoid excessive use of filters in a reactive application, since these can add overhead and reduce performance. Instead, use appropriate caching or offload processing to a separate thread pool using operators like subscribeOn().
  9. Excessive use of blocking adapters: Avoid excessive use of blocking adapters in a reactive application, since these can block the event loop and reduce performance. Instead, use non-blocking or reactive adapters where possible.
  10. Not using reactive libraries: Avoid not using reactive libraries in a reactive application, since this can limit performance benefits. Instead, use reactive libraries like Project Reactor to take advantage of reactive programming concepts and performance benefits.