473,397 Members | 1,972 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,397 software developers and data experts.

A question about efficiency

I am developing a site which will be very dynamic. Most of the displayed
content will come from a database (MySql) via PHP.

Some types of pages will change frequently (something like a forum page
which is always having new content added to it) and others will only change
once a day (a new news item gets added, etc.).

Although I can optimise my queries and my PHP scripts, there is still the
potential for the site to get congested, once a large number of people start
accessing it.

The question is how do I make sure it performs well? There are several
options I might consider, such as:
- don't do anything, but rely on server caching. Is PHP / Apache caching
any good?
- Periodically "publish" my PHP-generated pages to flat HTML pages and serve
them up instead of the PHP.
- Other things?

Any thoughts?

--
Stephen Oakes
Jul 21 '05 #1
10 1301
Stephen Oakes wrote:
I am developing a site which will be very dynamic. Most of the displayed
content will come from a database (MySql) via PHP.

Some types of pages will change frequently (something like a forum page
which is always having new content added to it) and others will only
change once a day (a new news item gets added, etc.).

Although I can optimise my queries and my PHP scripts, there is still the
potential for the site to get congested, once a large number of people
start accessing it.

The question is how do I make sure it performs well? There are several
options I might consider, such as:
- don't do anything, but rely on server caching. Is PHP / Apache caching
any good?
- Periodically "publish" my PHP-generated pages to flat HTML pages and
serve them up instead of the PHP.
- Other things?

Any thoughts?

--
Stephen Oakes


Hi Stephen,

I am unsure what you expect from the first solution.
Is there any way Apache/PHP can cache requests that depend on
databasecontent that changes all the time?
I don't think so, but maybe I am wrong. (Happens daily. :P)

You second approach is easy to implement, and easy to understand.
I did it before, and it works realy easy.

The approach I choosed was a little different from the one you describe, but
similar:
1) I identified a bunch of pieces in pages that seldom change but need a lot
of Database-querying.
2) All those pieces were made include-files. Nothing fancy, just a plain
include.
3) I programmed on relevant 'triggers' (Not database-triggers) on places
where the includefiles were modified (mostly by an admin that changed
something in the database). These triggers simply called a routine that
rebuilded the included files.
In this way you:
- do not need a cronjob or anything like that.
- And all your includefiles are always up to date. Immediately.

Of course, it is up to you to decide which pieces on your site are suitable
for this approach.

Just my 2 cents.

Regards,
Erwin Moller

Jul 21 '05 #2

"Erwin Moller" <si*****************************@spa.com> wrote...
- don't do anything, but rely on server caching. Is PHP / Apache caching
any good? - Periodically "publish" my PHP-generated pages to flat HTML pages and
serve them up instead of the PHP. - Other things?
I am unsure what you expect from the first solution.
Me too, that's why I asked. I don't really know enough about how
server/mysql caching works to know whether I need do anything extra.
You second approach is easy to implement, and easy to understand.
I did it before, and it works realy easy.

The approach I choosed was a little different from the one you describe,
but
similar:
...
Yes, that's the basic approach I had in mind, although more on a per-page
basis than part-page. That idea might help in some places.
Of course, it is up to you to decide which pieces on your site are
suitable
for this approach.


Did you notice any improvements in speed?

--
Stephen Oakes
Jul 21 '05 #3
Stephen Oakes wrote:

"Erwin Moller" <si*****************************@spa.com> wrote...
- don't do anything, but rely on server caching. Is PHP / Apache
caching any good? - Periodically "publish" my PHP-generated pages to flat HTML pages and
serve them up instead of the PHP. - Other things?
I am unsure what you expect from the first solution.
Me too, that's why I asked. I don't really know enough about how
server/mysql caching works to know whether I need do anything extra.


So maybe there are great solutions out there that work great, we both don't
know about.
:-)
You second approach is easy to implement, and easy to understand.
I did it before, and it works realy easy.

The approach I choosed was a little different from the one you describe,
but
similar:
...


Yes, that's the basic approach I had in mind, although more on a per-page
basis than part-page. That idea might help in some places.

In my case I had a few lists (top10 like stuff) that appeared on several
pages. So a small piece of HTML in an include made the most sense in my
situation.
Of course your situation might differ, and you need complete pages: but
principle is the same, I expect.

Of course, it is up to you to decide which pieces on your site are
suitable
for this approach.
Did you notice any improvements in speed?


Yes.
Some of the queries I needed took up a lot of time (because of quite complex
calculations needed to produce the top10 lists).

I would like to add that the above solution is really easy to implement.
Instead of writing the html to output, you just put it into the appropriate
file.

Of course the user PHP/WWW-data/nobody/whatever needs writepermission in the
directory where you store these files. That is why I made a special
directory for it, because I didn't want that that user had writepermission
on all my files, so in case of a securitybreach, the damage would be
limitted to those includefiles.

Hope this helps you a bit.

Regards,
Erwin Moller

--
Stephen Oakes


Jul 21 '05 #4
My advise is to wait till you have a congestion problem before dealing
with it. Unless the success of a site is somehow guaranteed, your focus
should be on making it a success, instead of worrying about it becoming
too successful.

Jul 21 '05 #5
NC
Stephen Oakes wrote:

I am developing a site which will be very dynamic. Most of the displayed
content will come from a database (MySql) via PHP.

Some types of pages will change frequently (something like a forum page
which is always having new content added to it) and others will only change
once a day (a new news item gets added, etc.).

Although I can optimise my queries and my PHP scripts, there is still the
potential for the site to get congested, once a large number of people start
accessing it.

The question is how do I make sure it performs well? There are several
options I might consider, such as:
- don't do anything, but rely on server caching. Is PHP / Apache caching
any good?
- Periodically "publish" my PHP-generated pages to flat HTML pages and serve
them up instead of the PHP.
- Other things?


Consider MySQL query caching...

Cheers,
NC

Jul 21 '05 #6
In article <11*********************@g14g2000cwa.googlegroups. com>,
"Chung Leong" <ch***********@hotmail.com> wrote:
My advise is to wait till you have a congestion problem before dealing
with it. Unless the success of a site is somehow guaranteed, your focus
should be on making it a success, instead of worrying about it becoming
too successful.


This is the best advice I have read in a long long time!

So many people focus on problems that aren't even there...

And this kind of problem is a "good problem" to have. Hopefully when it
happens, you will be making some money to buy the resources to fix it.
Jul 21 '05 #7
"NC" <nc@iname.com> wrote in
news:11**********************@g44g2000cwa.googlegr oups.com:

Consider MySQL query caching...

this will make a HUGE difference for the type of application you are
proposing.... it is not enabled out of the box, but it's easy to set up.

http://www.databasejournal.com/featu...le.php/3110171
Jul 21 '05 #8

"Scott Auge" <sc********@yahoo.com> wrote...
My advise is to wait till you have a congestion problem before dealing
with it. Unless the success of a site is somehow guaranteed, your focus
should be on making it a success, instead of worrying about it becoming
too successful.


This is the best advice I have read in a long long time!


hmm...yeah, but not if the subsequent "dealing with it" involves an entire
architectural redesign.

Frankly I'd rather at least know what my options are before I build the
system.

Thanks to those who've replied; there've been some helpful ideas.

--
Stephen Oakes
Jul 21 '05 #9
Stephen Oakes wrote:
I am developing a site which will be very dynamic. Most of the displayed
content will come from a database (MySql) via PHP. .... The question is how do I make sure it performs well?


1. All pages are generated by 404 script. First time page is generated,
second time it's just a static page.

2. When you change your data, engine must delete from disk generated
pages which depends on this data. For each class you need method
returned list of URL to delete if this object is changed.

3. When you develop design have in mind this approach. Separately
changed objects in database must be presented by separately cached
objects in URL space. For example in you make shop don't insert HTML
code with current basket info right to page with product info. It must
be _separate_ object: iframe, frame, included javascript file, etc... In
this case you can make product info page static. And it will be
regenerated only when product is changed.

Lazy way.
Jul 28 '05 #10
Stephen Oakes wrote:
<snip>
Although I can optimise my queries and my PHP scripts, there is still the
potential for the site to get congested, once a large number of people start
accessing it.

<snip>

FWIW, <news:11*********************@z14g2000cwz.googlegr oups.com> (
http://groups-beta.google.com/group/...63108151657c33
)

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Jul 28 '05 #11

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

Similar topics

6
by: Steve M | last post by:
1. Near the beginning of the document "Unifying types and classes in Python 2.2" by GvR, which can be found at http://www.python.org/2.2.2/descrintro.html, the author writes the following about...
1
by: Laser Lu | last post by:
Whether it can improve the execution effciency of ASP by centeralizing the often used code into header files and then including these header files in ASP pages? -- Best regards, Laser Lu
10
by: Scotter | last post by:
Please forgive me for reposting; last title didn't quite say it right. I have an ASP application I wrote in vbScript so this is not .Net. There are 20 nearly identical versions of this...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
2
by: zhege | last post by:
I am a beginner of C++; I have a question about the std:string and std:cout class; Two pieces of code: -------------------------------- #include <iostream> #include <string> using namespace...
335
by: extrudedaluminiu | last post by:
Hi, Is there any group in the manner of the C++ Boost group that works on the evolution of the C language? Or is there any group that performs an equivalent function? Thanks, -vs
2
by: yicong | last post by:
hi,All could you tell me which case is more efficiency?(my tables have no index) And does it has any else case more efficiency? case1: "select sum(Invoice_Production.Quantity) from...
23
by: TefJlives | last post by:
Hi all, I'm learning a bit about C, and I have a few questions. I'm not trying to insult C or anything with these questions, they're just honestly things I don't get. It seems like pointers...
9
by: OldBirdman | last post by:
Efficiency I've never stumbled on any discussion of efficiency of various methods of coding, although I have found posts on various forums where individuals were concerned with efficiency. I'm...
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:
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
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.