Cómo hacer que php y mysql usen diferentes núcleos
Frecuentes
Visto 150 equipos
0
Kinda struggeling with mysql again...
Setup: vServer with 4 Cores, 1 gig RAM. Ubuntu 12.04 LTS, Serverpilot installed Apache (behind NGinx), PHP and MySQL.
When I run a script (runs kinda long, a few hours), it uses exactly 1 core - about 70% php, the rest mysql. Not stable of course, sometimes mysql isn't active at all, etc.
Is there a way to make mysql run on a different core? Connect to mysql via external IP does not solve it... ;-)
¡Muchas gracias!
2 Respuestas
0
I fear that your problem is that PHP is not a Threaded language. There are no good ways to do parallel processing in PHP (hilos de rosca looks promising, but I was not able to build it successfully last I tried), which is probably what you really would need to speed up this script.
Respondido el 12 de junio de 14 a las 15:06
0
Check out numactl (http://linux.die.net/man/8/numactl) which you can include in your launcher for mysql. You could also use cset and taskset depending on what your distribution recommends, but that's how you can bind any process to a single core or package.
Respondido el 12 de junio de 14 a las 11:06
The question is irrelevant. When your PHP accesses the MySQL database the PHP is put on hold (blocking), so it's not actually using any core at all at that point. Which core MySQL then uses is neither here nor there as they're all available for use. To more effectively use multiple cores you need to rethink your script to work in a parallel fashion. - Majenko
If you really want to force the CPU affinity of a process, which won't speed up your script, this is how: cyberciti.biz/tips/… - Majenko
Thanks for your responses, sorry left it there for a few days. It still seems strange to me, that it looks like MySQL and PHP together use exactly one cores power but I will try to setup pthreads. - moay