Performance Impacts in Reactive Programming
reactive
Performance Impacts in Reactive Programming
- 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.
- 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().
- 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.
- 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().
- 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.
- 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.
- 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.
- 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().
- 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.
- 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.