Monday Mar 30, 2015

How To Use Jersey Client Efficiently

While fixing a memory leak issue in JerseyClient some time ago i realised how easy it is to misuse the thing. In this blog post, i would like to introduce some tips to avoid unnecessary memory allocation and also to save some CPU cycles to achieve better throughput.

Tip 1: Be careful when updating WebTarget config!

In Jersey 1.x it was suggested to reuse Client instances (see here for details). In Jersey 2, reusing Client instances is still recommended, but as such it is not sufficient to keep things running efficiently. Application performance can easily be undermined here. Related documentation could be found in Jersey User Guide and the key sentence is quoted bellow:

The configuration principles used in JAX-RS client API apply to WebTarget as well.
The documentation does not state this explicitly, so i will write it here in bold once more: be careful when touching configuration of a web target!. What does it mean? Whenever you create a new web target with updated configuration, Jersey will effectively create a new client runtime. To keep your application performing well, you should think of reusing all such web targets.

Best practices

The following picture depicts penalty that you could pay if you do not avoid the two main anti-patterns in this area. The graph captures total time required to make 50 thousand of HTTP get requests via Jersey client calls.

Tip 2: Avoid WebTarget.register()

If you need to register some extra components, do it on the client already to prevent another client runtime creation. If you need another runtime, just try to register things once and reuse the resulting target instance.

Tip 3: Avoid WebTarget.property()

The same applies to updating properties. These you can happily set on an Invocation or its builder

Tip 4: Use response.close() to release network connections!

When i wrote a simple test to get data for the above graph, i was getting short of available network ports. The problem is well described e.g. here. To avoid this i had to close responses. So as the last tip i recommend you close coming responses as well.

Monday Mar 16, 2015

Jersey 2.17 Has Been Released

We have just released the 2.17 version of Jersey, the open source, production quality, reference implementation of JAX-RS 2.0.

To download Jersey 2.17, please check out our download page.

You can also check out the refreshed Jersey 2.17 documentation:

This version includes mainly bug fixes. Following is a list of the most important updates:

Thursday Feb 12, 2015

Jersey 2 Performance

During my sabbatical week in January i have done some performance improvements in Jersey server core module. These changes are already included in Jersey version 2.16.

To make sure the changes indeed made a positive difference i have re-established continuous performance testing for Jersey server side processing. These automated tests allowed Michal Gajdoš to collect some numbers that show how performance evolved within Jersey 2.x version space. In this post i would like to share part of the outcome of this measurement. I hope to be able to reveal more numbers and details on the test setup in later posts.

The above graph shows how Jersey throughput increased with increased Jersey version. Version 2.4 is emphasised here as till that version we had a serious bottleneck in Jersey, that avoided throughput to scale with increased number of worker threads.

The above numbers capture increased throughput for regular resource methods handling plain text payload, where no sub-resource locators are involved. Sub-resource locators used to have poor throughput in Jersey versions prior to 2.16. In 2.16 Michal fixed this and i would recommend you check out his post on this topic here.

I think that the above graph clearly shows that we take performance seriously in Jersey. I hope that we will be able to further improve performance of Jersey in future versions.

Wednesday Feb 22, 2012

Jersey 1.12 is released

We have just released the 1.12 version of Jersey, the open source, production quality, reference implementation of JAX-RS. The JAX-RS 1.1 specification is available at the JCP web site and also available in non-normative HTML here.

For an overview of JAX-RS features read the Jersey user guide. To get started with Jersey read the getting started section of that guide. To understand more about what Jersey depends on read the dependencies section of that guide. See change log here.

This version includes mainly bug fixes. The biggest update is Jersey asynchronous client switched internally from using Netty to Grizzly 2 client implementation. Grizzly 2 dependency was upgraded to version 2.2.1.

For feedback send email to:

users@jersey.java.net (archived here)

or log bugs/features here.

Besides 1.12, we have been working hard on our first public milestone for Jersey 2.0 and I am happy to let you know we have released that as well - see Marek's blog post for more details. As a result, Jersey 1.x releases may become less regular and we don't expect to add any bigger features going forward, as Jersey 2.0 becomes our main focus. We are planning to add some new exciting stuff there in the following months, so stay tuned!

Friday Nov 04, 2011

Jersey 1.10 is released

Yesterday, we have released the 1.10 version of Jersey, the open source, production quality, reference implementation of JAX-RS. The JAX-RS 1.1 specification is available at the JCP web site and also available in non-normative HTML here.

For an overview of JAX-RS features read the Jersey user guide. To get started with Jersey read the getting started section of that guide. To understand more about what Jersey depends on read the dependencies section of that guide. See change log here.

The major breaking change is we separated Servlet, EJB, and CDI functionality out from the jersey-server module and put this Java EE related stuff to a new, jersey-servlet module. Then when deploying into a Servlet container, you will need to add one more dependency (on that jersey-servlet module).

A similar change happened also to our jersey-grizzly2 module, where if you need the Grizzly Servlet server, you will newly need an additional, jersey-grizzly2-servlet dependency.

Another breaking change happened in the WADL area, where Pavel and Marek worked on improving and fixing bugs.

Last but not least, Pedro Kowalski from the user community contributed stream support to the jersey-multipart module.

For feedback send email to:

users@jersey.java.net (archived here)

or log bugs/features here.

Monday Sep 05, 2011

Jersey 1.9 is released

On the last Friday, we have released the 1.9 version of Jersey, the open source, production quality, reference implementation of JAX-RS. The JAX-RS 1.1 specification is available at the JCP web site and also available in non-normative HTML here.

For an overview of JAX-RS features read the Jersey user guide. To get started with Jersey read the getting started section of that guide. To understand more about what Jersey depends on read the dependencies section of that guide. See change log here.

Jersey artifacts are finally available in the central maven repositories. I.e. when using maven, you should not need to specify the <repositories/> tag any more. Snapshot versions of Jersey will become available in a new Java.net maven repository.

Besides a number of bug fixes, the major additions included in this version are: non-blocking asynchronous client feature (moved over to the contribs space from the experimental area, see Pavel's blog for details), FreeMarker support and WADL improvements made by Gerard Davison (see his blog post here), which allows you to automatically attach XML schema to the generated WADL.

For feedback send email to:

users@jersey.java.net (archived here)

or log bugs/features here.

About

Jakub Podlesak-Oracle

Search

Archives
« May 2015
SunMonTueWedThuFriSat
     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
      
Today