Damian U
Damian U

Reputation: 381

Webflux - does jaxb can affect to performance of reactive application?

I have webflux application which mainly parse xml and returns json response. Max xml size which app handles is about 9MB, just like json response.

Problem is that my application throughput is only 16TPS.

I spent a few days on debugging my application to discover what is wrong and I think JAXB is a bottleneck.

I've tried few JAXB improvements like unmarshal from byteInputStream instead of StringReader etc.

So, my question is, does jaxb isn't adapted to reactive applications?

Upvotes: 0

Views: 979

Answers (1)

kaqqao
kaqqao

Reputation: 15459

What your application is doing sounds mostly IO-bound, as it parses (relatively big) documents that it reads from the request. Reading the stream is likely slow (depends on the network as well) and parsing XML is not the fastest thing either (I don't know what else you need to do to prepare the response).

While you could offload both of these tasks to a different thread-pool:

  1. Don't block the client thread while reading the request (easily doable by using e.g. Mono<RequestBody> in Spring, instead of RequestBody)
  2. Use a non-blocking parser as @Strelok helpfully commented

unless your app is also doing something else in the meantime (that's where the other things you do come into the picture), you're not really benefitting from the reactive architecture. This is generally true for all IO-bound apps. Reactive architecture doesn't jive with mostly-IO tasks very well.

Of course, everything I said is mostly conjecture, as I haven't seen any of your code nor have any insight into your app. But these are some general guidelines. It is impossible to give a more accurate answer without knowing exactly what is going on inside your app, and what are the actual numbers. Even then, it could be rather involving. (Btw, this is likely why someone (not me) voted to close your question)

Upvotes: 1

Related Questions