473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

What is php's behavior when connect to a db?

What is php's behavior when connect to a db?

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
system performance.

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
request?
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.
thanks.

Nov 9 '05 #1
1 1684
ze********@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.


Nov 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jack Smith | last post by:
I am unable to connect to certain SQL servers from PHP on IIS. I have two IIS 5 servers, both are Windows 2000 Server boxes with PHP 4.3.4 and MDAC 2.80.1022.3. I have three SQL Server machines...
3
by: Todd McNeill | last post by:
Hi- I'm getting some rather strange behavior with PHP4 on Debian Linux accessing a DB2 V8.1 box on AIX. I've recompiled PHP "--with-ibm-db2" support. I'm able to connect to the database just...
2
by: xiuchuanli | last post by:
I install Fedora 4 with web server, after that I installed mysql 5.0.15. Now I can connect to mysql from command line and mysql-administrator and mysql-query-browser. But when I try to test to...
4
by: d3vkit | last post by:
Okay so I am at a loss here. I have a website that I've previously had no trouble connecting to the mysql DB on. I have an include to a connect file with the relevant connection info, and it was...
3
by: bb nicole | last post by:
I have did the company login and job post which means that company can post the job after they login in my webpage.. I had set company_ID(tablename:company) is foreign key of table job. But when i...
3
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
17
Motoma
by: Motoma | last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/. Introduction:...
2
by: dgbergman | last post by:
I have created a php login page in my site for my company. The goal is to get people into members area. Below is a list of steps that I take to create my login page in Dreamweaver CS3, can some one...
12
by: Jerry | last post by:
I tried to turn on magic_quotes_gpc behavior shows that it is Off phpinfo shows it is Off phpinfo shows path to config file as C:\php\php.ini setting: magic_quotes_gpc = On in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.