[jax-rs-spec users] [jsr339-experts] Re: Overhead of AsyncResponse

From: Bill Burke <>
Date: Wed, 07 Nov 2012 13:59:15 -0500

On 11/7/2012 11:50 AM, Jan Algermissen wrote:
> Hi,
> do you have an estimate what the overhead of using an AsyncResponse is, if you send back a sync. response for the majority of cases?
> Use Case:
> Implement a resource method that retains the opportunity for handling a request asynchronously but decides thatonly when the method is actually invoked. IOW, when the method determines that a synchronous response is fine, it simply invokes the async response right away.
> Does that significanly affect performance or resource usage?

I don't know. I could do a mini bench vs. JBoss Web Servlet container,
but I"m too lazy.

BTW, I have a similar use case that I've discussed before:

void post(@Suspended AsyncResponse res) {

    res.resume(Response.status(202).build()); // 202, Accepted

    // do an expensive op.


In this case, the client gets a response immediately, while the server
does something in the background. Really simple, no need for queues,
threads, etc.

Bill Burke
JBoss, a division of Red Hat