Introduction
In the post Integrate Java and GraphicsMagick – Conception, I have expressed the performance concern of im4java’s integration approach. In order to verify whether the issue actually exists, we implemented our first beta application using im4java to run the baseline test.
Application
This is a web application that dynamically resize the source images that is 700x700 or less to a smaller dimension. An HTTP request come in with the individual image and the target size specified, the web application locates the source image and resize it to the target size, then streams the image back to the requester, typically a browser.
The application simply use “gm convert <source> –scale <width>x<hight> <target>”, which is probably the fastest way to scale down an image. We have throttled to only run max 32 gm processes at any given time because we got the best throughput with that setting.
Test Environment
Hardware
RAM: 32GB
CPU: 32 cores - 4 AMD Opteron(TM) Processor 6274 (8 cores)
Test Tool
JMeter is used to execute the test. The machine runs the JMeter has identical hardware as the test machine. There is high speed network connection between them.
Test Setup
We used 200K unique sample image and each image are being request twice, one converts to 260x420 and another converts to 114x166.
On thread group is used to run multiple threads in parallel. Each thread represent one concurrent user. We run the test multiple times, with different number of concurrent users. Each thread will request image one after another, there is no delay whatsoever.
We measure the throughput in terms of total number of images resized within a second by the server.
Test Result
Table below listed the total throughput under different load.
Concurrent Users | Total Throughput (images/second) |
---|---|
50 | 278 |
500 | 109 |
5000 | 19 |
20000 | 4 |
The throughput degrades significantly when number of concurrent user increases, it performs worst when we need it most under high load. The throughput isn’t idea even at 50 concurrent users considering it is running on such a powerful server.
Conclusion
It is clear that we need a better solution than this. We also want to make it clear that the bottleneck is not the im4java, as it simply constructs the command line and invoke the GM process. The major overhead is spawning the new process. The test simply proves that the overhead is huge for JVM to spawn a new process, especially when it has large amount of open file handlers for socket connect.
Finally, we set out to implement our proposed solution.
Other Posts in the “Integrate Java and GraphicsMagick” Series
- Conception
- im4java Performance
- Interactive or Batch Mode
- gm4java
- gm4java Performance