SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Help With The Easiest Logic

    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 ?

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Put the four servers behind a load-balancer, then access the load-balancer instead of the servers directly. By-the-way, I am referring to a hardware based load-balancer not software. Trying to emulate a load-balancer in PHP is foolhardy nor reliable.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Addict kduv's Avatar
    Join Date
    May 2012
    Location
    Maui, HI
    Posts
    211
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    You could also store "last_used_server_id" in a database. Then when there's a page visit, just pull the last_used_server_id from the DB and use that to determine which server to use next.


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
  •