debian - How to share CPU resource to run PHP script faster? -


i have php script load 1 cpu of 8 cpus 100 percent. can share cpu resources run php script faster?

now when start php script, load 1 cpu 100%. other have 1-5% load. because of script performed 40 second.

can share load across processors, or impossible?

firstly: if you're cpu bound 40 seconds chances need rethink algorithm or programming language. php imho still best user facing, html/json/whatever output format producing engine. that's why it's built on shared nothing architecture: 1 request gets 1 cpu, computes , terminates. scale architecture on multiple cpus distributing requests among them.

that said, if single request takes 40s complete, might have luck using worker threads, need spin off main thread , can run on under-utilized cpus. again, that's whole mountain of complexity scale - think hard before starting down route.

a easier alternative do-it-yourself thread management fork out work dedicated worker processes. gearman known framework this.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -