“Match Making” script, a way without involving the database and php?

I am writing a matchmaking script for a game through a web portal. For the past few days I have been looking into the different options and I believe the following approach would be the most optimal but I would like the opinion of others.

  1. Get players match requirements through a web form (Method GET) and place the player in queue (mySQL database entry with time stamp and match requirements) for 1 hour.
  2. On the submit page run an ajax script every minute that contacts a php script that checks the following:
    • Is a player still in the system, if their hour is over or their ajax script has not ran in 5 minutes remove them from the database. Return time out.
    • Is the player in queue flagged for a match?
      • If yes then place both players in the in match table and remove both players from queue and send match variables.
      • If no then continue.
    • Do the remaining players match the current players requirements?
    • If yes:
      • Is the player the same one looking for a match.
      • If no: Return match variables. Flag other player.
      • If yes: Return match not found.
    • If no: Return match not found.
  3. When match variables are received the page will be updated with jquery, including a new ajax request that will call a new php script every 30 seconds to find out if both players accept the match. Possible ajax results are: 0 waiting, 1 accepted, 2 declined. There will also be a button that will send the players response immediately to the php script through ajax that will disable itself through jquery when pushed. When both players accept the page will then use jquery again to display the instructions for beginning the match.

Is there a cleaner or less intensive way to do this with or without involving the database and php?

Notes:
No code is written yet.
The system will not have more than 100 players in queue at any time. (Most likely a peak of 25)

Since you woun’t have that much players, I wouldn’t recommend on spending too much time on this issue, but continue on your other services.

I would use an AJAX script that scans off a php script every second, where the PHP script is looking for an opponent.

How would it work?
– A “Find match” button calls an external PHP script via AJAX

  • The PHP script checks if the player with the matching login hash is in a queue, if not add the player, then search for an opponent, and return the results
  • If the player is in the queue (On second or more calls), it skips the queue registration and immediately starts searching for an opponent
  • If a match is found, create a “matchfound”-table with various states, such as “waiting for player 1” / “waiting for player 2” / “player 2 declined” etc
  • With this information being sent to the 2 clients each second, you just pass on the current state in json to the clients, where you then have your presentation code (with for example a turning wheel when waiting for opponent etc)

This system would support alot of players, but if you’re aiming on creating a large match making system with thousands of players simultaneously, you should consider looking into other solutions then JavaScript/PHP, where socket-usage would be the best solution.

I suggest you look into websockets (like pusher.com or it’s open source variant slanger or socket.io). It allows you to keep connections with clients open and thus see whether players are still active or not. It removes your need for ajax calls to any backend.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật