eclipse-ee4j / eclipse-ee4j/jersey
Performance issue when using a static response variable in Jersey 2
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
In Jersey 2.x , I used to keep a reference to a **static variable**:
`final static EMPTY_RESPONSE = Response.noContent().build();`
When I load test (using JMeter), I simply return the static variable for an incoming HTTP (GET) request and the performance is very low compared to generating the response per request (using the ResponseBuilder).
Here's the GET API call:
```
@GET
@Path(DEBUG_PATH + "/empty")
public Response getEmptyResponse() { return EMPTY_RESPONSE; }
```
The CPU goes to 100% in both cases, but the performance **drops from 30K RPS to 150 only** when using the static variable.
BTW, I don't see this issue in Jersey 1.x.
Contributor guide
Assessment
This issue has not been assessed yet.