Speed of PHP (through a CDN)

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
tad
Forum Newbie
Posts: 5
Joined: Sat Mar 24, 2007 3:21 pm

Speed of PHP (through a CDN)

Post by tad »

I work for a CDN. I've been trying to get my boss to let me implement a CMS into the corporate website because things are constantly being updated and I'm the only one that can do it. His drawback of this is that using PHP might significantly slow the process of displaying the content of the site. Since we're a CDN our content should be faster than a normal site. I'd like to know what thoughts people have as far as speed when people are using PHP to generate dynamic content.

Here's how the CDN works (in case you're not familiar with the term): With the way we're using it for our site, we have all of our files in a server that we own that is our origin. Instantly, all of our larger file types are cached throughout our various servers all over the world (everything but HTML and PHP files - maybe some others.) So when someone grabs a page - say with a video on it and some images (all of which are cached the CDN) - in London it loads at the same speed as where my origin server is located here in the States - really fast.

The potential problem is if that video is called by a PHP script it may load "pretty fast" instead of "really fast" everywhere and we'll say that, in this case, its a significant difference because of the time it takes for the php to call that video from the network. Does anyone think that this may be the case? Please let me know what you think. Hopefully, I can talk my boss into it so that I won't have to keep resorting to using static HTML pages.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Can you explain what exactly a CDN (aside from a Canadian ;)) is and how it determines which server to load the content from.

It sounds like you are dealing with geographically targeted mirroring.

If implemented correctly, php shouldn't hurt things.
tad
Forum Newbie
Posts: 5
Joined: Sat Mar 24, 2007 3:21 pm

Post by tad »

It's not necessarily geographical but whichever rout is the fastest with our CDN. However, yes, that plays a part. Say that I have a large library of music that I's like to get to my target audience which is a lot. If I use a regular hosting company based in Canada (eigh :wink: ) A single person in Tokyo may be able to see it but it would take longer than a single person in Canada. If my audience is large then that dude in Tokyo would have an even longer lag time because of everyone listening to my sweet jams at the same time. At this time I may be so popular that even my Canadian friends may know what that dude in Tokyo is talking "aboot."

If I used a CDN at this time this amazing music library would be cached on thousands of servers. So when Jo Tokyo jumps online the same time as Sally Canadian and all of her thousands of friends he's jammin' out just as if he's the only one on the server and it's right down the street (because this probably is the case.)

So now you know about a CDN (which may be based in Canada, but isn't the same.) As much as I just realized that I like talking about it, the only think it has to do with my question is my reason for using static HTML as opposed to a PHP CMS (I want it to appear significantly faster than the sites someone's use to.) Given that, would you say that a dynamic PHP site runs significantly slower than if I had my whole site in static HTML pages?
Last edited by tad on Sat Mar 24, 2007 4:50 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I fail to see how it is possible to cache large amounts of binaries over thousands of servers.. so I doubt I'll be of much help. But what is the deal with these static html pages -- are you caching the html or the binaries?

Just so you know, you can implement php caching systems easily. Also, the http protocol is not the best method for file transfer, have you considered other protocols?

One more thing.. it's eh not eigh :wink:
tad
Forum Newbie
Posts: 5
Joined: Sat Mar 24, 2007 3:21 pm

Post by tad »

Actually, the HTML and PHP files don't get cached. Files such as images and videos and music are (and for some reason CSS.) A CDN is a service for larger companies that want to make their files seen faster and better (like when you go to ABC.com to watch the latest episode of "Lost.") We do also stream and and use other various delivery methods including HTTP. But that's beside the point.

I'm really just looking for a theory behind the how fast PHP renders HTML as opposed to a static HTML page. Caching is something that I can already do well. But thanks for being so responsive.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

PHP is typically really fast unless you are serving the large files through the php intepreter (which would slow things down a bit, ie readfile()), although I take it your CDN handles that. If all your doing it serving dynamic html with php, I wouldn't worry "aboot" speed or memory, eh?.
tad
Forum Newbie
Posts: 5
Joined: Sat Mar 24, 2007 3:21 pm

Post by tad »

Thanks a lot! That's all I was worried about. Maybe, with this input, I'll be able to drop my static pages and setup a nice CMS... pending my boss's approval.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

One thing is still puzzling me. What the heck does CDN stand for?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

nickvd wrote:One thing is still puzzling me. What the heck does CDN stand for?
http://acronyms.thefreedictionary.com/CDN

Consolidated Data Network I believe
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I nearly choked on my bacon when I read this, eh!

RRRRROLL UP THE RIM!

:rofl:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Kieran Huggins wrote:I nearly choked on my bacon when I read this, eh!

RRRRROLL UP THE RIM!

:rofl:

... to win..

No point of rolling the rim if you don't want to win.. unless you are some weird rim roller.. :lol:
tad
Forum Newbie
Posts: 5
Joined: Sat Mar 24, 2007 3:21 pm

Post by tad »

Actually, I meant CDN as in "Content Delivery Network" http://en.wikipedia.org/wiki/Content_Delivery_Network
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I never win :-(

For all the other confused people:
http://en.wikipedia.org/wiki/Tim_Horton ... Rim_to_Win

Tim Horton's is such a Canadian institution that we actually distribute new coinage through them instead of the bank... much more efficient that way.
Post Reply