Php/Mysql Architecture in High Traffic Site

Discussion in 'PHP' started by MakeADifference, Sep 21, 2008.

  1. #1
    What is "recommended architecture" for a website based on PHP/Myql/Apache on high traffic website?

    Planning to have multiple load balanced servers (atleast 3-4 apache), should need couple of DB servers as well. How does the session share happen in case of multiple front end servers? Do Databases replicate in real time?

    Has anyone implemented any such solution? I could not find anything online yet. Please share if you have done something like this (or come across any such article online).

    Much Appreciated.
     
    MakeADifference, Sep 21, 2008 IP
  2. Feral

    Feral Active Member

    Messages:
    70
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    68
    #2
    sessions and cookies are based on the web address. so unless you are having people go to your sites by ip address there won't be any problem with using multiple servers for the front end as long as you make the cookie access able from the whole site.

    As for the database, i'm not sure what you mean by replicate. If you want to use multiple db servers you would have to create the process to do so.

    I'm not sure what type of site you are wanting to create that you think you will need so much power behind it. A single dedicated server and a lot of bandwidth is good enough for the most robust blogs and forums and even most video sharing sites (no including youtube)
     
    Feral, Sep 21, 2008 IP
  3. thing2b

    thing2b Member

    Messages:
    45
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #3
    What I have learnt about high traffic sites is only use sessions and cookies when you really have to. For example an article site would not need to use sessions and cookies for 99% of page views. Only when some one needs to long in to edit an article should you use sessions and cookies. If this is done right, the 1% of the time that people do need to log in can be handled by 1 server. The rest can be handled by a distributed caching system.

    Do not share sessions between load balanced servers, you are asking for trouble. Instead make sure that the same server handles a users request each time. Do this based on the requesting IP. If you have 3 servers then redirect users according to the following:
    Server 1 IPs: 1.1.1.1 to 100.100.100.100
    Server 2 IPs: 100.100.100.100 to 200.200.200.200
    Server 3 IPs: 200.*.*.* to 255.*.*.*
    E.T.C

    The best solution is still caching though. If you can not cache an entire page, cache half of it (the output of a function or 2 for example). This will reduce cpu and db load.
     
    thing2b, Sep 21, 2008 IP
  4. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #4
    JEET, Sep 21, 2008 IP