M
M
merinovkv2015-02-25 18:28:26
PHP
merinovkv, 2015-02-25 18:28:26

How to run PHP script from console on all cores?

Tell me, gurus, is there any way to run php scripts from the console (linux, php 5.3), using all the cores at once? In short: there is a script that should not be run often, but write a lot to the database, while the requests are not large and there are a lot of them (over 100000).
Now the script works, but it loads only one core and works for a long time (7 hours each). Maybe there is some possibility from linux to specify the maximum number of cores for php?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Benkovsky, 2015-02-25
@benbor

No, PHP is single-threaded by default. You can run many scripts by hand (or not by hand, but by supervisor, for example) but they must be written appropriately, and not do the same job. And also, before optimizing something, first find a bottleneck, xhprof for example, and then eliminate it

A
Alexey L, 2015-03-20
@Niemi

if the distribution allows, then taskset can be used ("taskset - retrieve or set a process's CPU affinity
"). however, it is necessary to test how the application will react to this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question