Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- What is php's behavior when connect to a db?
November 9, 2005, 3:18 pm
rate this thread
I've been told that php was once a dominant web programing language.
I've read a few chapters of a php book.
I was wonder what's php's performance.
Perl was once for a while a popular programming language for cgi.
But start very process per one web visit cause serioius problem to
And then FASTCGI born.
I was impressed by its performance.
But recently i learn to do some php program which connect a mysql db.
It seems that the program run's very slow.
So, I have 2 questions:
1. does the os need to fork a php interpreter for every single web
2. does the php connects to mysql all the time? that is does it need to
100 times when a user request the url 100 times?
If the answer if yes, i think that php's performance is unacceptable.
Re: What is php's behavior when connect to a db?
depends on the database and the programmer.
It still IS.
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.
Yes, that helped a lot.
I made Perl resident in memory, right?
And some precompiling-tricks too.
I expect PHP has little to do with that tough...
How did you install PHP?
On which OS?
Did you install ISAPI under Windows?
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.)
Well, why don't you read up bit at php.net?
(PHP 3, PHP 4, PHP 5)
mysql_connect -- Open a connection to a MySQL Server
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.