Answer the question
In order to leave comments, you need to log in
How many socket connections should a real-time mobile application have and how are such applications created?
Now I am creating a mobile application. While the number of users is not known, but, potentially, there may be hundreds of thousands.
The stack, I think, does not matter, but I will write, suddenly it will help answer the question:
React Native for, in fact, the application, because. cross-platform + good knowledge of js + UI speed is not critical, and there are no resources for native development.
PHP (Laravel) for admin and API, as everything is ready out of the box + more than 4 years of experience with it.
Golang for built-in messenger because of the ease of working with networking and sockets out of the box.
Java to solve the main purpose of the application, because multithreading will be needed + I would like standard OOP, which is not in golang.
I realized such a thing that I do not understand how applications are created, where there are a lot of real-time events. For example, take the VK application. There, the wall is updated in real time, friends, messages arrive in a bunch of chats, and so on. I can't figure out how this is done? Each chat, wall, friends, etc. are listened to by a separate socket?
As I see it - When a user logs into the application, you need to open a websocket connection to the server and listen to various events. The server, when events occur, sends them to the client in something like this
type: 'message', data: {text: 'привет', chanelId: 1}
type: 'friendRequest', data: {user: {'name' : 'Вася', id: 1, avatar 'src'}}
Answer the question
In order to leave comments, you need to log in
It's better for you to keep one connection to Firebase or RabbitMQ from your mobile phone (Paho MQTT, if you want without native libraries).
Do everything else on the server, I used Firebase as a matter of fact as a cache with realtime updates for better scaling.
As I see it - When a user logs into the application, you need to open a websocket connection to the server and listen to various events.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question