views:

77

answers:

3

I am working on a huge php application with Zend framework, in that project we need to process files and create thumbnails for images, videos, documents for which we are using imagemagick, ffmpeg, openoffice in background process. To make the process optimized and fast with minimum resources I am thinking of implementing this process using another language may be java or c.

What you people suggest

  1. Stick with PHP
  2. Use Java
  3. Use C
A: 

If your processing is using external tools mainly, you can stay on shellscripts.

Then you just run 1-2-4-8 scripts in background which run constantly, fetch & process pieces of work and you are done.

Going C++/java is way longer to implement with very little benefit on this task.

BarsMonster
I need to use database connectivity to fetch the files which need to process and to get priority, I dont know whether this is possible with shell script or not
Sandeep Manne
You can with no problems. Any database have commandline tool where you can execute any query and fetch results. Also, you can implement these background tasks in PHP itself, so that you can share codebase. Then you will run PHP scripts directly via PHP instead of Apache.
BarsMonster
You can write Shell scripts in PHP, and there you can reuse the code already written to access the database.
jigfox
+1  A: 

Whatever language you use including PHP, you can use Gearman to initiate and manage the background processes for the heavy lifting.

Your Zend PHP application will create "jobs" and send them to Gearman, who will then dispatch them to "workers" who will perform them and report back, while your application can go on and not block. Said workers can be in a multitude of languages including PHP.

Fanis
What will the best language for multi thread processing
Sandeep Manne
Use the one you are most familiar with. Like jigfox answered below, you'll just be using that language to start up ffmpeg etc via system calls.
Fanis
+3  A: 

I really would stick with PHP. Here are the Reasons:

  1. No need to learn another language, or if you don't need to:
  2. If you want to hire someone new, he only needs to understand php
  3. You probably can reuse some code written for the app itself.
  4. you only need the php to start and configure things like imagemagick, ooffice and ffmpeg. They are already written in C/C++ and they do the heavy lifting. Your PHP code is just the glue between these programs. What's the matter if you can save some milliseceonds until a ffmpeg process starts when it's running several minutes.

IMHO it's not worth it to use C/C++ to start these processes.

jigfox