P
P
Poloskun Raccoon2020-08-04 15:53:07
JavaScript
Poloskun Raccoon, 2020-08-04 15:53:07

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'}}


Handle these events in some Redux and update components that are subscribed to the redux store.

But here the question is - how much can the server keep open sockets? Google shows that it's about 65k (although maybe I'm not so Googled). What if there are 100,000 users? What if a million?

Where it is possible to esteem as it is implemented in large applications? Google search does not return any results.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Georgy Khromchenko, 2020-08-04
@Mox

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.

O
Oleg, 2020-08-04
@402d

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.

Dose regimen for mobile applications.
If the operating system considered that the application is not really needed by the user, then access to
the network in the background will first be 1 time per hour, then 2, 4, up to 1 time per day.
So, opening a connection and listening to events will not work.
In addition, do not forget that mobile phones move and the network is not available from time to time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question