Click to See Complete Forum and Search --> : Developing for high traffic volume sites...


cwilkey
01-29-2007, 09:59 AM
All,

I'm developing some sites that are completely(almost) database driven. These sites will be generating very high volumes of traffic. Originally, I developed as one might think is typical - each of the dynamic pieces had their own database calls, however after doing some research, I've found that writing object oriented PHP is a much more effective way to go.

Does anyone have an input on this topic? I'd be very interested to know how others are doing it.

MrCoder
01-29-2007, 10:18 AM
OOP is just another way of doing the same thing. Badly programmed OO code is just as slow if not slower then badly coded non-OO code.

bokeh
01-29-2007, 01:48 PM
Badly programmed OO code is just as slow if not slower then badly coded non-OO code.And well written OO code is slower than well written non-OO code.

If the site is really high traffic look into caching built pages.

NightShift58
01-29-2007, 06:44 PM
To extend the comments made by the two previous members, I would like to add that you will find that OO is perhaps a boon to the developer/programmer, giving you many more little blackboxes that may (or may not) make the development process easier.

As such, you may find that it is easier - and faster - to develop an application. So far, so good. When it comes to running the application, you'll find a different story unfolding before your eyes, especially with PHP.

If you take C++, OO makes more sense because the whole application is pre-compiled. With PHP, scripts tend to be (re-)compiled on the fly, requiring the various classes to be recompiled and, since OO also tends to have a large code overhead, that will lead to a reduction in performance .

Even properly coded, as Bokeh mentions, OO in a PHP run-time environment will usually be slower than the seemingly less-elegant household version.

In three words: Don't do it...

pcthug
01-29-2007, 08:26 PM
OOP (Object-Orientated Programming) generally evaluates to more maintainable, portable, structured code. Just because working with objects may leave a little larger overhead footprint, that's no reason to not use them [objects]. That's like the use of functions; they may slow performance by a few nanoseconds, but hey, I'm not going to retype 150 lines of the same code every time I need to log an error.

With todays available technology, hardware is cheap. Programmers are not. If you'd like to boost your performance upgrade your server hardware, don't diminish your code.

If you take C++, OO makes more sense because the whole application is pre-compiled. With PHP, scripts tend to be (re-)compiled on the fly, requiring the various classes to be recompiled and, since OO also tends to have a large code overhead, that will lead to a reduction in performance .
You can cache your objects (object code caching); your objects are cached and thus performance is increased. See: IonCube (http://www.ioncube.com/), Zend Safeguard (http://www.zend.com/products/zend_safeguard).

Another type of caching to consider is content caching, you could custom code this yourself or make use of one of the various templating systems. My favourite is Smarty (http://smarty.php.net/)

You may also want to look into Distributed object caching systems. Such systems cache the majority of your database data into memory resulting in immediate performance boosts. See: MemCached (http://www.danga.com/memcached/).

You may also want to look into output compression and optimizing your database queries.

NightShift58
01-30-2007, 01:25 AM
If I can't talk the OP out of going OO, maybe I'll convince him to at least stay away from Smarty...

For a high volume traffic site... humm... definitely should try this: http://yats.sourceforge.net/

bokeh
01-30-2007, 10:40 AM
If the site is really high traffic look into caching built pages.This is what is really going to save your server some work, a lot more than coding style.

cwilkey
01-30-2007, 07:03 PM
Thank you all for your comments. I take each of them in serious consideration.