Need Help With The Easiest Logic

Discussion in 'PHP' started by Bohra, Jul 31, 2012.

  1. #1
    ok so i need help in sorting out the easiest way to do this

    i have 4 diffrent servers from where i can pull data what i want to do is

    In the first visit it pulls data from server 1 then from the second visit it pulls data from server 2 then from server 3 and then from server 4 and 4 is used again back to 1

    right now i am doing this using php random but it wont equally distribute it this way

    can u tell me how to do this the easiest way ?
     
    Bohra, Jul 31, 2012 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Use a cookie. Then have the script check for the cookie, increment by 1, and reset the cookie each time. This way you are pulling data from servers and it will survive the user leaving and coming back.

    You could also use a session variable if you would prefer not to set a cookie, but it will reset if the browser is closed or the session times out.
     
    jestep, Aug 1, 2012 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #3
    What business problem are you trying to solve here? Load balancing? Rotating users around the servers assumes everyone returns 4 times - the server #1 is still going to get the bulk of the bandwidth requests etc.
     
    sarahk, Aug 1, 2012 IP