I have an action in a controller that generates and returns a custom
png-file, it goes something like this:
#1 gather some userdata from params.
#2 make a system call to an advanced java application that renders a
png based on the custom data. stores the png on disk.
#3 read the png into rails
#4 send the png to the browser with method send_data
#5 delete the png from disk
The problem is that the png-rendering takes very long time, ~2 seconds,
and consumes a lot of the cpu resources. During this time the rails app
become totaly locked up, not handling any incoming requests from other
I would like to have this method run in its on lower priority thread. Is
I have tried to put the system call in a thread but that that didnt
work, the main execution seemed to go on when the png was generating,
resulting in a file not found error when trying to do step #3. And
putting all steps in the thread block also didnt work, the png data was
never received by the browser.
Any thoughts on how I can solve this problem?