473,398 Members | 2,335 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,398 software developers and data experts.

What's slowing things down?

Hello all -

I have a problem with a php page. I have a setup with Apache 2.0, PHP
5 and Postgres 8.1 on Debian 4.0. My script uses simplexml to parse
large xml files ( 8 files at 2-15 MB ea. ) and do inserts into the
database.

The problem is twofold. One, output on the parsing page seems to come
in starts and fits. I have a message to the user that gets echoed each
time parsing a file is finished; but these messages come all at once,
like two or three at a time. In other words, the message doesn't come
when the parsing is finished; they seem to build up. It's a simple
loop so I don't think the problem is in the program

Also, when I am going through the parsing loop for a set of files, the
rest of the site doesn't respond until the looping is over. The
parsing seems to basically stop all web serving.

How can I find out if the problem is with Apache, PHP, or Postgres?

Jul 10 '07 #1
6 1708
..oO(la*****@gmail.com)
>The problem is twofold. One, output on the parsing page seems to come
in starts and fits. I have a message to the user that gets echoed each
time parsing a file is finished; but these messages come all at once,
like two or three at a time. [...]
Try flush() to force a flushing of the output buffer.

http://www.php.net/flush

Micha
Jul 10 '07 #2
NC
On Jul 10, 12:26 pm, lawp...@gmail.com wrote:
>
I have a problem with a php page. I have a setup with Apache 2.0, PHP
5 and Postgres 8.1 on Debian 4.0. My script uses simplexml to parse
large xml files ( 8 files at 2-15 MB ea. ) and do inserts into the
database.

The problem is twofold. One, output on the parsing page seems to come
in starts and fits. I have a message to the user that gets echoed each
time parsing a file is finished; but these messages come all at once,
like two or three at a time. In other words, the message doesn't come
when the parsing is finished; they seem to build up. It's a simple
loop so I don't think the problem is in the program
This is normal behavior; either your server :

http://www.php.net/flush
Also, when I am going through the parsing loop for a set of files,
the rest of the site doesn't respond until the looping is over. The
parsing seems to basically stop all web serving.

How can I find out if the problem is with Apache, PHP, or Postgres?
All of the above. When you start parsing and writing the results into
the database, PHP and Postgres lean very heavily on both memory and
CPU, so there is almost nothing left for the rest of your
application. Run top during parsing and see for yourself.

Cheers,
NC

Jul 10 '07 #3
On Jul 10, 7:42 pm, NC <n...@iname.comwrote:
On Jul 10, 12:26 pm, lawp...@gmail.com wrote:
I have a problem with a php page. I have a setup with Apache 2.0, PHP
5 and Postgres 8.1 on Debian 4.0. My script uses simplexml to parse
large xml files ( 8 files at 2-15 MB ea. ) and do inserts into the
database.
The problem is twofold. One, output on the parsing page seems to come
in starts and fits. I have a message to the user that gets echoed each
time parsing a file is finished; but these messages come all at once,
like two or three at a time. In other words, the message doesn't come
when the parsing is finished; they seem to build up. It's a simple
loop so I don't think the problem is in the program

This is normal behavior; either your server :

http://www.php.net/flush
Also, when I am going through the parsing loop for a set of files,
the rest of the site doesn't respond until the looping is over. The
parsing seems to basically stop all web serving.
How can I find out if the problem is with Apache, PHP, or Postgres?

All of the above. When you start parsing and writing the results into
the database, PHP and Postgres lean very heavily on both memory and
CPU, so there is almost nothing left for the rest of your
application. Run top during parsing and see for yourself.

Cheers,
NC
I tested Apache serving a static HTML webpage, and that got served up
in a timely manner during parsing.

I understand Postgres getting bogged down with selects and inserts,
but there's only one instance of the PHP parser than can parse web
pages? That if one PHP script is bogging down on the server, all PHP
scripts will be bogged down?

Jul 11 '07 #4
On Jul 11, 1:40 pm, lawp...@gmail.com wrote:
>
I tested Apache serving a static HTML webpage, and that got served up
in a timely manner during parsing.

I understand Postgres getting bogged down with selects and inserts,
but there's only one instance of the PHP parser than can parse web
pages? That if one PHP script is bogging down on the server, all PHP
scripts will be bogged down?
Actually, I did some more testing, and it looks like postgres is the
culprit.

I can serve static HTML pages while parsing, I can spit out data from
infinte loops in php while parsing, but I can't seem to get data from
other queries when doing a bunch of inserts.


Jul 11 '07 #5
la*****@gmail.com wrote:
On Jul 11, 1:40 pm, lawp...@gmail.com wrote:
>I tested Apache serving a static HTML webpage, and that got served up
in a timely manner during parsing.

I understand Postgres getting bogged down with selects and inserts,
but there's only one instance of the PHP parser than can parse web
pages? That if one PHP script is bogging down on the server, all PHP
scripts will be bogged down?

Actually, I did some more testing, and it looks like postgres is the
culprit.

I can serve static HTML pages while parsing, I can spit out data from
infinte loops in php while parsing, but I can't seem to get data from
other queries when doing a bunch of inserts.

Each new connection to the server starts a new process or thread
(depending on your OS and Apache version) to handle the request. So you
have multiple PHP parsers running.

What you're probably running into is locking in PostGres. When you're
inserting or updating rows, PostGres can lock rows or tables so that
queries don't get partially updated data or data which hasn't been
committed.

The result is SELECT statements will wait until you COMMIT or ROLLBACK
the INSERT or UPDATE transaction (or close the connection).

This is standard for virtually all databases.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 11 '07 #6
On Wed, 11 Jul 2007 18:11:35 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>What you're probably running into is locking in PostGres. When you're
inserting or updating rows, PostGres can lock rows or tables so that
queries don't get partially updated data or data which hasn't been
committed.

The result is SELECT statements will wait until you COMMIT or ROLLBACK
the INSERT or UPDATE transaction (or close the connection).

This is standard for virtually all databases.
Virtually all databases now implement (or have the option to implement)
multiversioning. For example, Oracle, MySQL with InnoDB table handlers, and I
believe recent versions of SQL Server, and from a quick search, PostgreSQL has
done for ages.

Multiversioning means that readers don't necessarily get blocked by
uncommitted writers.

The resources used for maintaining the "old" view of the data can be exhausted
of course, but in Oracle that produces an error for the reader ("snapshot too
old") rather than a lock - other databases may react differently.

Concurrent writers for the same data will still obviously contend with each
other.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 11 '07 #7

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

Similar topics

7
by: John T. McDougald | last post by:
I am using a Win XP Home system and I have had a problem ever since I first bought it. Whenever I am on the net and come on to a web site that has a Jaava enabled website, my system slows down...
16
by: TheKeith | last post by:
I'm writing a script with a while loop in it. How can I get it to go slower so that it doesn't appear to happen all at once--so that it looks animated--basically. I tried the setTimeout(500) in the...
15
by: Jean | last post by:
Hello, I have the following query that I set up as a test, and it runs fine: SELECT STATUSHISTORIE.* FROM STATUSHISTORIE LEFT JOIN PROBLEM_DE ON STATUSHISTORIE.PROBLEM_ID =...
3
by: Dan Stromberg | last post by:
I have two different python programs that are slowing down quite a bit as their memory use goes up. I'm not really sure if this is some sort of CPU cache effect, or if it's something about...
7
by: Chris Thompson | last post by:
Hi All, I have a private website created using HTML/PHP. Within this site, there is a page that has a form (question.php), which is populated depending on the question number that has been...
3
by: Gummy | last post by:
Hello, I have an ASPX page on which I place a UserControl 15 times (they only need to be static controls on the page). This UserControl is a set of two listboxes with radiobuttons above the...
34
by: radink | last post by:
Well, I've got my DB ready to go. Now what? I need to host it on our Win2003 server. How do clients use it? I think im getting more confused as I try to figure this out. We are a small company...
1
by: =?Utf-8?B?QWRwcm9m?= | last post by:
Since I installed OneCare I have noticed my computer slowing down significantly. Has anyone else experieced this?
3
by: karl98 | last post by:
Does anyone else experience slowing down of a web conferencing session when 5 or more people join in the meeting? Our web conferences slow down considerably and are driving me nuts.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.