问题
In my project I have to send user's location periodically (E.g. 30Sec) to server using Android application and the PHP server returns nearest users and app displays them on the map. I am looking for a publish subscribe protocol for the real time data transfer.
Here is the architecture I was planned. Each mobile app users id will be considered as a topic or channel so that we can send response to each user. PHP server will considered as a topic e.g. "APP_SERVER_TRACKER". All mobile apps publishes location to Server topic. Server prepares the list and publish response to individual user's by using their id as topics.
I would like to know how my PHP Backend Server subscribe topic? In reality all my users are connecting to my PHP Backend Server using a single channel via PubNub. After getting location of each user server process it and publishes response to end user. In this scenario do I need to scale my PHP Server? Is there a way for directly handling all my customer request within the PHP Server itself? Please advice?
The application will target at least 10 Million users. should support half of concurrent users. PHP Server Hosting will be in AWS EC2 m3.2xlarge 8 core instance. Please let me know if AWS Server configuration is adequate?
回答1:
PubNub Geohash Use Case
You don't need your PHP server to do this. Just have your Android app subscribe
to a channel that is what is call a geo-hashed channel (a channel name based on your location). Your app will also publish
its location to that channel.
So now you are receiving location updates from others near you while at the same time you are sending your location to those that are near you.
See PubNub Geohash use cases for more details.
来源:https://stackoverflow.com/questions/35497355/pubnub-integration-with-php-server-and-android-application