We're working on a server using spring 4, embedded jetty 9 and jersey. Recently, we moved to jersey 2.13 and we noticed a degradation in performance. I performed some investigations using YourKit. I saw that there is a massive CPU usage in reflection done by jersey. Also, there are many NoSuchMethodExceptions
and ClassNotFoundExceptions
in Yourkit snapshot.
Are there any jersey configuration or a best practice to avoid this issue, or to optimize jersey? Or maybe it is a known issue in jersey 2?
Here are two screenshots from YourKit, showing the hot-spots, after excluding the socket read (java.net.SocketInputStream.socketRead0
). The first one is with Merged Callees:
And the second one is with Back Trace:
Thanks.
RESTful service development (on Jersey) is an architecture, which inherently uses servlets. JAX-RS compliant tools like Jersey provide easy marshalling-unmarshalling of XML/JSON data, helping the developers. REST helps us use GET/POST/PUT/DELETE in a fashion that is far efficient than normal servlets.
Both Jersey and RESTEasy provide their own implementation. The difference is that Jersey additionally provides something called Chunked Output. It allows the server to send back to the client a response in parts (chunks).
JAX-RS is only a specification and it needs a compatible implementation to be used. On the other hand, Spring MVC is a complete framework with REST capabilities. Like JAX-RS, it also provides us with useful annotations to abstract from low-level details.
Jersey is an alternative to Spring RESTFul applications created with @RestController . Spring is a popular Java application framework for creating enterprise applications. Spring Boot is the next step in evolution of Spring framework.
By looking at your question I can not pin point the exact issue. But I can suggest you to check the following things:
If you are using maven to build your project, then I suggest using the maven dependency tree plugin to check the above mentioned points.
- Chiru
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With