Developer’s Corner: High Performance JPEG Encoder for GeoServer
Dear all,
We would like to talk about some work we did lately to add support in GeoServer for encoding JPEG GetMap responses using the libjpeg-turbo library.
Citing its website the libjpeg-turbo library is a derivative of libjpeg that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems. On such systems, libjpeg-turbo is generally 2-4x faster than the unmodified version of libjpeg, all else being equal. I guess it is pretty clear now why we wrote this extension!
The work was done in a quite modular manner. We created an ImageIO Writer and Reader hosted by the ImageIO-Ext Open Source project and then we created a community extension for GeoServer to use the writer for encoding WMS GetMap responses. The extension should work fine on GeoServer 2.2.x, 2.3.x and 2.4.x (a.k.a master).
Documentation has been created as well, check here. Long story short, aside from the usual process for installing an extension (dropping its jars inside the GeoServer WEB-INF/lib directory) it is required to install the native counterpart for libjpeg-turbo for which there is enough instructions on the documentation linked above.
In order to provide some numbers on a typical use case we run a quick set of performance tests on a normal laptop with some sample data. Here is what we did:
Hardware
- Intel i5 quad-core
- 8GB RAM
- 500 GB HD (7200 RPM)
- GeoServer Master build
- libjpeg-turbo 1.2.1
- Oracle JDK 1.6.0_27 running in server mode
Conclusions
The GeoSolutions team,