I could make an AJAX request that displays the online users for each user. The request is done every 5-10 sec. or whatever. The problem is, isn't that overloading my server too much? Is there a way to do it that it will update the online users for everyone else instantly?
Asked
Active
Viewed 80 times
2
-
1If you have say 50 or 100 concurrent users, this will most likely not be a problem. However, if you have more you should look into longpolling, websockets or similar - here is some inspiration http://stackoverflow.com/questions/333664/simple-long-polling-example-code – davidkonrad Jul 03 '14 at 10:31
1 Answers
2
If you are looking for a system that can be used to indicate "Presence" events (Join/Leave/Is Typing/Geo/Lat/Long/etc) in real-time, you should check out PubNub:
Of specific interest to you would be the publish, subscribe, presence, and state APIs.
Both PHP and JS client SDKs are available:
https://github.com/pubnub/php http://www.pubnub.com/docs/javascript/javascript-sdk.html
geremy

Geremy
- 2,415
- 1
- 23
- 27
-
-
@GeorgeIrimiciuc you certainly can. But its another thing to write and maintain. Services like PubNub have written it already server-side and client-side, officially support it, and provide global HA/Failover, with geo-sensing to send users to the datacenter quickest to them. Its not trivial, but definitely possible to write your own. – Geremy Jul 08 '14 at 17:23