Re: How php works?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, December 13, 2006 12:15 am, Kai Xiang wrote:
> 1. I heard there is a zend engine inside PHP playing the role as a
> virtual
> machine, and PHP excution have 2 step, first compile to opcode and
> then
> excute the opcode,
> so is that means the php are compiled only once per file? or still
> need to
> recompile when another request issued to the server? also I heard
> about the
> caching extention about php, is it talking about caching the opcode?
> is't
> caching the opcode or excute results? how it shares between the
> requests?

There is a Zend Engine inside the guts of PHP, and it does compile to
opcode and execute.

You can buy or find "opcode cache" software that will cache the
compiled opcode and run that on the next request.

Note that the BIG win there is not the compilation, but the hard drive
not getting hit to load in the PHP script.

> 2. Is there some alternative choise except zend engineen, why need a
> zend
> engine? for performance advantage or just easy for porting to
> different
> platform?

The original PHP guts were a hand-crafted parser by Rasmus Lerdorf,
who, and this is NOT meant to be pejorative, had no idea what he was
doing :-)
He didn't know that there were tools out there to write new computer
languages, and didn't use them.
So his parser was, well, kinda buggy, actually.
Ze'ev and Andi gutted the system with a shiny new parser using the pro
tools for homework, and ended up being Core PHP Developers by
accident. :-)
So, that became the Zend Engine, as Ze'ev and Andi's idea of a Good
Time is not building PHP websites, but building cool tools to improve
the guts of PHP, which is also why they started Zend (http://zend.com)
to sell high-end tools to high-end customers, like the Zend Cache.

> 3. Take linux apache for example, if compiled as a apache module, and
> using
> prefork threading model, for example, if I have 100 process, is that
> means I
> have 100 copy of PHP library local data(I assume only one reentrant
> excutable image) in each process? compare to a worker model, like 10
> process
> and 10 threads in each one process, should it make a difference that
> we only
> have 10 copy of PHP library local data ?

Yes, but if you don't use prefork, you have some serious thread safety
Risks, particularly in the extensions, and most especially in any
extensions that aren't getting heavy use already by people trying to
push into the threaded environment...

Stick with pre-fork unless your testing budget is 10 X your dev budget.

> I'm not sure if this is the right place to talk about this, anyway, if
> you
> know a better place, help me out :)

This is probably about as on-topic a post as one can get, though much
of the info is "out there" if you can sift through the junk to find
it.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux