I'm trying to improve performance of captcha image rendering in web app running on Linux. Looking at what is currently used, I found that the bottleneck is in the usage of Java2D and specifically Graphics2D class.
The problem is not much with the speed of execution, but more with scalability. Basically it doesn't scale. Drawing of captcha images in 1 thread or 2 threads doesn't make any improvement in terms of execution time.
As an example, you can have a look at following class which is creating background for captcha images. The problem appears on calls to Graphics2D::setColor() and Graphics2D::drawLine():
After some googling and I found topic which says that Java2d is not particularly well with multi-threading (sorry, not allowed to give more than one link :) but, you can easily find that topic if google for 'java2d multithreading', it will be the first result)
I believe that there must be some library which provides drawing capabilities withtout using Java2d, but failed to find it :( Or Java2d, probably, can be switched to some mode, which doesn't block on access to graphics object (btw, headless mode doesn't help).
I will appreciate any suggestions. Beforehand, thanks for answers.