|
Posted by Erwin Moller on 11/07/34 11:31
zelzel.zsu@gmail.com wrote:
Hi zeszel,
> What is php's behavior when connect to a db?
depends on the database and the programmer.
>
> I've been told that php was once a dominant web programing language.
once was?
It still IS.
:-)
> I've read a few chapters of a php book.
good.
>
> I was wonder what's php's performance.
>
> Perl was once for a while a popular programming language for cgi.
Yes, I did a lot of Perl too, but I am really happy I can do almost anything
in PHP nowadays.
At least I am able to read my own code.
;-)
> But start very process per one web visit cause serioius problem to
> system performance.
>
> And then FASTCGI born.
> I was impressed by its performance.
Yes, that helped a lot.
I made Perl resident in memory, right?
And some precompiling-tricks too.
>
> But recently i learn to do some php program which connect a mysql db.
> It seems that the program run's very slow.
Not good.
I expect PHP has little to do with that tough...
>
> So, I have 2 questions:
> 1. does the os need to fork a php interpreter for every single web
> request?
How did you install PHP?
On which OS?
Did you install ISAPI under Windows?
etc.
Your question is a little hard to answer. :-)
In general: PHP is NOT slow, and can easily handle massive requests if the
underlying server is post-stoneage.
(Just my personal experience, based on PHP4/5 on RH8/FreeBSD/Windows2000
combined with IIS4/5/6 and Apache.)
> 2. does the php connects to mysql all the time? that is does it need to
> connect mysql
> 100 times when a user request the url 100 times?
>
> If the answer if yes, i think that php's performance is unacceptable.
>
Well, why don't you read up bit at php.net?
**************************
mysql_connect
(PHP 3, PHP 4, PHP 5)
mysql_connect -- Open a connection to a MySQL Server
Description
resource mysql_connect ( [string server [, string username [, string
password [, bool new_link [, int client_flags]]]]] )
Opens or reuses a connection to a MySQL server.
**************************
In general: Do not worry about PHP's performance.
Worry about the databasequeries.
Most of the time people write bad repetive queries, and blame PHP.
I am not saying you do that, but I just see it a lot.
;-)
So if your site is very slow, try this:
- where does the script take up its time?
- isolate the part where the database is queried, and measure the time it
needs to complete your query.
You can use a crude microtime to measure roughly. It is enough to pinpoint
to the problemerea without complex debugging/profiling tools.
Works for me untill now in all cases.
Good luck.
Regrads,
Erwin Moller
>
> thanks.
Navigation:
[Reply to this message]
|