Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to make PHP pages load lightning fast?
Old 03-21-2007, 05:19 PM How to make PHP pages load lightning fast?
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
How would i make my php pages load really, really fast. I know that it sometimes depends on the content but how would i do it any ways.

Note: i have tried to use ob_gzip lib or whatever but when i double refresh the page, its like it stalls and doesnt load? whats up with that?!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
 
Register now for full access!
Old 03-21-2007, 11:28 PM Re: How to make PHP pages load lightning fast?
Extreme Talker

Posts: 189
Trades: 1
If your server is slow then well, no way you can make it fast, get a faster host. There are also tutorials to optimize your server configuration if you can modify the server config, google them (i.e: apache optimization, mysql optimization)
Other than that, if your php read from database, make sure you optimize all the queries.
__________________

Please login or register to view this content. Registration is FREE
yellow1912 is offline
Reply With Quote
View Public Profile Visit yellow1912's homepage!
 
Old 03-22-2007, 01:30 AM Re: How to make PHP pages load lightning fast?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
The only way I know how to speed up PHP code is to code smart and use planning. The Zend Optimizer I think will help server performance on PHP parsing.

Using ob_gzip will actually slow your php runtime, all it does is compress the output to provide quicker download to your clients browser (in which the browser will have to decompress to render). If you use ob_gzip, make sure you are flushing the output buffer at the end, that might be your cause with the stalling as the client's browser is not receiving the output.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 03-22-2007, 06:55 AM Re: How to make PHP pages load lightning fast?
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
The only way to make php pages load fast is to store them as plain html files on server's hdd. Or at least implement some data caching in order to not fetch the same data from database on each and every request. In 95% cases the bottleneck is db connection (unless you perform complex calculations in your script) and in 99% cases the script is connecting to DB to fetch one and the same data which was last modified a month ago and will never be modified in future. Why not to store it somewhere like files?

All caching plugins like turck mmcache and zend accelerator only optimize your php code, which itself (without DB, calling external programs and fetching datafrom remote sites) executes in a fraction of a second. Thus php optimization will only save you if you don't turn to DB but calculate the PI number up to one thousand number after point. In all other cases it will be absolutely useless, you must optimize your db instead.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-22-2007, 08:20 AM Re: How to make PHP pages load lightning fast?
Defies a Status

Posts: 1,606
Trades: 0
Quote:
In 95% cases the bottleneck is db connection (unless you perform complex calculations in your script) and in 99% cases the
Comparing a DB fetch of a title and 500 word article versus "including" the same from a static source, would you make an estimate of 1. how much faster it loads and 2. how much less resources it uses?

I feel sure it is faster and less intensive. I just can't get a feel for how much.

I am also wondering if it is the size of the query or just the query itself that consumes the time. If you searched a DB that had only the title, a few keywords and a link to the static content would that be faster?
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 03-22-2007, 08:45 AM Re: How to make PHP pages load lightning fast?
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
First of all it depends on how are you fetching this article. If you do "select * from table where id = $n" and id is a primary key the speed won't differ significantly. But this is too simple case to implement caching on.

I was talking about the case when you, for example, need to extract categories tree from your DB and extract number of items in each category. If new items are added much rarely than they are selected then number of items doesn't change for a relatively long time and thus you make your DB server to perform complex operations to fetch the same data structure every time. In this case it is quite obvious that you should store ready for output array of objects in a file and update this file every time you add new item. I use this method in one of my sites myself.

Cosidering your question about searching the DB. It also depends. If you do a fulltext search on title, keywords and short summary it will be faster than ft search on title and 500 words article. Still if you need to perform ft search often you also can implement cache. Instead of making ft every time for a certain request you can do ft only first time and then store IDs of corresponding articles in separate table. It will allow you to select articles by ID instead of fulltext search. This method is also used by me in my another site.

Getting back to your title and 500 words. If the page containing this article has any information that is changed frequently (links to related articles, number of users online) you can store the preformatted article in a file and include it in the corresponding placeholder with readfile() instead of fetching it from DB. If the page does not contain such information you can generate a complete html page and send it to user without having to pass throgh php at all.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!

Last edited by mtishetsky; 03-22-2007 at 08:46 AM..
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-13-2011, 06:10 AM Re: How to make PHP pages load lightning fast?
Junior Talker

Posts: 2
Trades: 0
Any examples on how to do this ??
vimalsaifudin is offline
Reply With Quote
View Public Profile
 
Old 08-13-2011, 06:13 AM Re: How to make PHP pages load lightning fast?
Junior Talker

Posts: 2
Trades: 0
I have a large dataset and whwnever requesting this page it is going to database now.. Shouls we use xml file for loading data faster in this sequence?


Quote:
Originally Posted by mtishetsky View Post
First of all it depends on how are you fetching this article. If you do "select * from table where id = $n" and id is a primary key the speed won't differ significantly. But this is too simple case to implement caching on.

I was talking about the case when you, for example, need to extract categories tree from your DB and extract number of items in each category. If new items are added much rarely than they are selected then number of items doesn't change for a relatively long time and thus you make your DB server to perform complex operations to fetch the same data structure every time. In this case it is quite obvious that you should store ready for output array of objects in a file and update this file every time you add new item. I use this method in one of my sites myself.

Cosidering your question about searching the DB. It also depends. If you do a fulltext search on title, keywords and short summary it will be faster than ft search on title and 500 words article. Still if you need to perform ft search often you also can implement cache. Instead of making ft every time for a certain request you can do ft only first time and then store IDs of corresponding articles in separate table. It will allow you to select articles by ID instead of fulltext search. This method is also used by me in my another site.

Getting back to your title and 500 words. If the page containing this article has any information that is changed frequently (links to related articles, number of users online) you can store the preformatted article in a file and include it in the corresponding placeholder with readfile() instead of fetching it from DB. If the page does not contain such information you can generate a complete html page and send it to user without having to pass throgh php at all.
vimalsaifudin is offline
Reply With Quote
View Public Profile
 
Old 08-13-2011, 10:17 PM Re: How to make PHP pages load lightning fast?
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
Quote:
Originally Posted by vimalsaifudin View Post
I have a large dataset and whwnever requesting this page it is going to database now.. Shouls we use xml file for loading data faster in this sequence?
Why not do some simple page generation timings yourself and see what shows up.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to How to make PHP pages load lightning fast?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39630 seconds with 12 queries