I ran into a similar issue using ImageMagick’s convert program from a shell script.
I asked, but didn’t receive any guidance on what the various limits of CPU/Memory are that gets a process killed. Apparently, it also has to do with the load average of the host you’re on.
So, I think the politically correct answer is that you should create thumbnails on your local machine and upload them to the host for display.
My solution broke things up into the smallest tasks possible, and queued jobs to a temporary directory with a crontab that would continue trying every few minutes until it succeeded. Eventually, I’m planning on reading the current load average from /proc/loadavg and avoid launching such a task under high load averages.
Of course, I was just prototyping some code, and would probably go with a private server for production code so as to guarantee a certain level of service to my customers.