AiursoftWeb / Kahla.App

Kahla is a cross-platform business messaging app.
https://www.kahla.app
MIT License
415 stars 85 forks source link

Kahla 4.0.0 - Multiple region and private server support #785

Closed Anduin2017 closed 4 years ago

Anduin2017 commented 4 years ago

Kahla plans to introduce server switching in 4.0.0.

Why we do this

This is for users in many different regions, and these users do not need to download an additional Kahla app. For these users, multiple regions are imperceptible. The domain names they visit are web.kahla.app, and they download the same Kahla App and Kahla CLI. For example, if we deploy a Kahla server in Shanghai, China, all users in China will connect to this Kahla server in Shanghai.

For the future, there may be enterprises deploying Kahla App on their internal network. Multi-server Kahla allows data not to leave the corporate network, while users still use the same version of the Kahla app, and can switch between the public Kahla server and their private Kahla server at any time.

Also, this will encourage developers to deploy Kahla servers privately.

What data can be synchronized across servers?

The user's basic information, including ID, nickname, Bio, avatar, password, and log in log, data is exchanged between servers in different regions.

The user's friends, chat messages, stargate channels, files, theme colors, and privacy settings will not be synchronized.

Use case

Servers fetching algorithm

www.kahla.app will provide an API that allows querying the list of all servers currently registered. The return value will include the server address, the server's API level, and the server name.

Servers speed test algorithm

Kahla App will support server speed measurement use cases.

Its implementation is: Make an HTTP request to all servers in the server list at the same time asynchronously, requesting /. The difference between the time to start the request and the time to obtain the response is used to obtain the server lag value.

Servers selection algorithm

Kahla App will support the server automatic selection algorithm. Its implementation is:

Generally, a device will only execute the server speed test algorithm once and only once. Saved values will be used later.

Components to be changed

Landing page

In Kahla's landing page, the server's automatic selection algorithm will be triggered and the results of the server selection algorithm will be displayed.

image

When the user presses "Region: {Current Server Name} (Click to switch)", the server selection component should be displayed.

Server selection component

image

In the server selection component, all the servers returned by the server list algorithm will be displayed.

Users can see the server name. Users can view the results returned by the server speed measurement algorithm. If the API level of the server is not consistent with the Kahla App, the user will display a warning when trying to switch, but it does not prevent him from continuing to connect.

There should be one on the list: called Other Kahla Server. If the user presses this item, he is asked to enter the address of his own Kahla server.

Anduin2017 commented 4 years ago

This requirement comes from one of my friends who wants to deploy Kahla again in Japan but shares the same Kahla app from our public version.

While we do this, the environment for Kahla.App is still only one: https://web.kahla.app. And region acceleration is based on CDN.

Anduin2017 commented 4 years ago

Possible server list response:

[
    {
        "serverName": "East Asia",
        "serverAddress": "https://server.kahla.app",
        "serverPublicKey": "BJOTNmtE1V5GyDiYtoUzWbWLiaVMyfdnXFTvneJCbi9mwpw7FAVgQgIR9JN43TWkpT7ezBes1fPYr4nPqV6qXA0",
        "serverAPILevel": "3.9.1"
    },
    {
        "serverName": "Japan",
        "serverAddress": "https://jp.server.kahla.app",
        "serverPublicKey": "BJOTNmtE1V5GyDiYtoUzWbWLiaVMyfdnXFTvneJCbi9mwpw7FAVgQgIR9JN43TWkpT7ezBes1fPYr4nPqV6qXA0",
        "serverAPILevel": "3.9.1"
    },
    {
        "serverName": "Australia",
        "serverAddress": "https://au.server.kahla.app",
        "serverPublicKey": "BJOTNmtE1V5GyDiYtoUzWbWLiaVMyfdnXFTvneJCbi9mwpw7FAVgQgIR9JN43TWkpT7ezBes1fPYr4nPqV6qXA0",
        "serverAPILevel": "3.9.1"
    }
]
Anduin2017 commented 4 years ago

The API to get server list:

https://staging.kahla.app/servers

In production mode, will be changed to:

https://www.kahla.app/servers