Instant Challenge/Notifications system
My setup: Currently running a dedicated server with an Apache, PHP, MYS开发者_高级运维QL. My DB is all set up and stores everything correctly. I'm just trying to figure out how to best display things live in an efficient way.
This would be a live challenging system for a web based game.
User A sends a challenge to User B
User B is alerted immediately and must take action on whether to Accept or Decline
Once User B accepts he and User A are both taken to a specific page that is served up by the DB (nothing special happens on this page,and they dont need to be in sync or anything)
The response from User B is a simple yes or no, no other parameters are set by User B, the page they are going to has already been defined when User A sends the challenge.
Whichever config I implement for this challenge system, I am assuming it will also work for instant sitewide notifications. The only difference is that notifications do not require an instant response from User B.
I have read up on long polling techniques, comet etc.. But im still looking for opinions on the best way to achieve this, and make it scalable.
I am open to trying anything as long as it will work with (or in tandem) to my current PHP and MYSQL set up. Thanks!
You're asking about Notifications from a Server to a Client. This can be implemented either by having the Client poll frequently for changes, or having the Server hold open access to the Client, and pushing changes. Both have their advantages and disadvantages.
EDIT: More Information
- Pull Method Advantages:
- Easy to implement
- Server can be pretty naïve about who's getting data
- Pull Method Disadvantages:
- Resource intensive on the client side, regardless of polling frequency
- Time vs. Resource debacle: More frequent polls mean more resource utilization. Less resource utilization means less immediate data.
- Push Method Advantages:
- Server has more control overall
- Data is immediately sent to the client
- Push Method Disadvantages:
- Potentially very resource intensive on the server side
- You need to implement some way for the server to know how to reach each individual client (for example, Apple uses Device UUIDs for their APNS)
What Wikipedia has to say (some really good stuff, actually): Pull, Push. If you are leaning toward a Push model, you might want to consider setting up your app as a Pushlet
精彩评论