SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: PHP Scalability

  1. #1
    SitePoint Zealot yukimushu's Avatar
    Join Date
    Feb 2005
    Location
    United Kingdom
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Scalability

    Hey people,

    I'm just wondering what the scalability of PHP is like.

    I'm looking at making a questionaire application in PHP; the largest project i've worked on - which could potentially have anywhere between 1,000 to 5,000 people on it in one go, answering somewhere upto 200 questions; all database driven using MySQL.

    Would the average dedicated server tooled with PHP/MySQL be able to handle this kind of demand?

    Is there anything that would you suggest or recommend me look at?

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    scalability is a very broad term - It's almost impossible to give a clear answer to your question.

    From a technical viewpoint, PHP performs reasonably well, and its architecture makes it fairly simple to add new hardware. It integrates nicely with the whole Linux eco-system, so you can move performance intensive parts out of PHP an into binary extensions.

    On the software side of things, PHP lacks a bit. If you don't know what you're doing, you can very easily create a mess of an application for your self. It's not as bad in this regard as some try to make it though.

  3. #3
    SitePoint Guru
    Join Date
    Jun 2006
    Posts
    638
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Think facebook uses it... or used it.

  4. #4
    SitePoint Member
    Join Date
    Apr 2002
    Location
    London, UK
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yukimushu View Post
    ...
    Is there anything that would you suggest or recommend me look at?
    I'd suggest keeping the database queries to a minimum.

    A PHP script making 10, 20 or more mySQL queries to render a page will perform fine when developing with only 1 simultaneous user, but once you've got 100's of simultaneous users thats 1000's of simultaneous database queries.

    Simplest way to do reduce the number of queries without having to modify the database driven side of the site much is to cache any database query results that isn't changed very often, and use the cached data to render the page instead of retrieving it from the database.

    Depending on how dynamic each page is, you could also / alternatively cache the HTML output for each page the first time its requested, and serve that directly the next time the page is requested bypassing php completely.

    Zend framework has a number of options available for caching (haven't used it myself, but the documentation seems informative).

  5. #5
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like any dynamic scripting language, PHP scales pretty well up to a certain point. That threshold depends on how your app is setup, but it's probably somewhere around 1,000+ requests per second (which is really quite a lot).

    You will be hitting filesystem/database, memory, and web server bottlenecks long before you'll ever get near actual PHP bottlenecks. There are things you can do with PHP to ease these issues, like caching and refactoring, as mentioned above. So you may actually find that PHP is the tool to prevent you from hitting bottlenecks.

    Now I did open my post by saying "up to a certain point". The nice thing about PHP in particular is that it uses native C libraries for it's extensions. So the really big sites using PHP (Digg, Facebook, Yahoo!, etc.) have quite a bit of code in their own custom C libraries rather than actual PHP code because it's compiled, and thus much faster than interpreted PHP.

    So the answer is: Yes, PHP will scale. But the code starts shifting more towards custom PHP extensions (coded in C and compiled) after a certain point.

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the php way of scalability is horizontal. the problem in horizontal
    scaling is to replicate the state of your application between the
    nodes.
    you should have an idea how to implement sessions if they're
    heavily used. (vanilla php sessions won't work)
    databases are, of course, an problem too. you should know
    how to optimize the usage of them and how to scale them (ie
    replication).

    [edit]
    these are tools that would help you if you need to scale:
    http://en.wikipedia.org/wiki/Load_balancer (ie. pound, nginx)
    http://en.wikipedia.org/wiki/Database_replication
    http://dev.mysql.com/doc/refman/5.0/en/replication.html
    http://en.wikipedia.org/wiki/Memcached
    http://framework.zend.com/manual/en/...ends.memcached

    each one cares about one problem, the concrete product is
    up to you.

  7. #7
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You also need to think about usage patterns. Assuming you have 5000 users on it at a time, how many page requests are they actually making? How long are they looking at a page before navigating to the next? There are different problems to be addressed by looking at concurrent usage and volume usage as separate problems.

  8. #8
    SitePoint Addict
    Join Date
    Jan 2008
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    php scales very well (fcgi mode patched with php-fpm)

    but dont use apache, nginx is much better

    mysql is fine assuming your database is well designed and tweaked


    speaking from experience here running several large sites on own servers
    ( 333 000 visitors / 1 742 000 pageviews a day )


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •