Development for dual core machine
Bryan Olson
fakeaddress at nowhere.org
Sun Aug 19 09:10:31 EDT 2007
Andy wrote:
> I'm going to develop a software package that includes a web server
> (and PHP code) , a database, and some Python code of course. I am
> being strongly suggested to make it to work on a dual- or multi-core
> computer, but I'm confused on how to take advantage of the multiple
> CPUs.
>
> From what I read, I think that simply by making the package run in
> several separate processes (web server, database server, Python
> interpreter, etc.), and/or using multiple threads (which I will
> anyway) the package should be able to use multiple CPUs.
Right. There is a theoretical possibility that Python's GIL
could limit thread parallelism, but in this kind of application
it should not matter in the least. Either you're I/O bound, or
there are plenty of tasks the operating system could schedule.
If you have the option to run the Python interpreter within a
web-server process, that's usually a performance winner.
> Is my understanding correct? So actually, all I have to do is just
> write my multi-threaded Python code as usual? And how is it decided
> which process and which threads go to CPU 1, CPU 2, etc.? Perhaps the
> BIOS?
The O.S. actually. A lot of really smart people have put a whole
lot of work into making the O.S. do that well.
If you usually write your Python apps multi-threaded, as I do,
that's fine. Multi-core efficiency has only a little to do with
it. Web service are, for the most part, intrinsically
parallelizable: run multiple web servers, and multiple Python
interpreters serving multiple connections.
The only hard part is shared data. Scalability is all about
the database.
--
--Bryan
More information about the Python-list
mailing list