0

I written one high performances script in php. Which takes 30 ms time to execute.

now i have make this script more sealable so i have done rnd on following points. What i am looking is the do parallel processing on chunk of the code to minimize the time 30 ms to 15 ms and more distributes so script can serve more requests.

  1. Gearman

i am done some rnd on gearman using it's asynchronous task handler i can achieve parallel task in php code.

  1. C++

Second option is convert entire php script into c++ extension which helps to improve the scrip and in c++ i can also use threads.

all this i am planning so i need help they are other ways i can scale the script?

can c++ helps in parallel processing?

PHP Connect
  • 539
  • 2
  • 7
  • 24

2 Answers2

0

You can try to chunk your workload into pieces and let multiple gearman workers run your task (parallel). Not sure if it will be faster though.

Mauricio
  • 11
  • 1
0

Yes, you can easily convert your PHP algorithms into C++ code, I do that all the time with pieces of our software that are too slow in PHP. I have in fact started a library for it that could be useful, and that makes this conversion very simple: see http://www.php-cpp.com.

Converting from PHP to C++ alone already gives a big performance boost. Going from 30ms to 15ms is not at all unusual by just converting an algorithm from PHP to native C++. If that alone is not yet enough, you could start up multiple threads. I can not advise you how to do that, because I would have to know your algorithms to see if they are suitable for splitting up in threads. But the C++11 std library now comes with a thread class, that makes this simple.