enfein/mieru

Mita Server Support Large-Scale Users

Platon929 opened this issue · 7 comments

I encountered a problem with our Mita server client while attempting to add a large number of users (10,000) at once. The client, Mieru, isn't working properly in this scenario, resulting in a timeout error. However, it operates correctly when adding a smaller number of users under normal circumstances.

enfein commented

This is expected. When a new connection is established, the server will iterate all the users and try to decrypt the message, which can take a long time if the number of users is huge.

The limit depends on the performance of server machine.

It is better to load balance users to different machines.

There's no problem with the VPS; it has 32GB of RAM, and only one user is connected, yet I'm experiencing a timeout issue. I created 3 servers with fake json config files for XTLS Xray(2GB RAM), Singbox(2GB RAM), and Mieru(32GB RAM), but the problem only occurs with Mieru. Could you please check it? Thank you.

I believe there are issues with the code that make iterating over all users unnecessary. Instead, we can utilize the array index to verify if a user exists. While I'm not well-versed in Go language, this approach is applicable in other programming languages.

enfein commented

I got your point. This is achieved with TLS. Client encrypt the user info with server's public key. Server uses the private key to decrypt, and get the user info. Server uses the same private key to decrypt all incoming requests.

No TLS was the initial design goal of this project (https://github.com/enfein/mieru/blob/main/docs/announcement.zh_CN.md). I don't want to complicate everything by bringing in it.

enfein commented

There are some ways to mitigate, for example: run decryption in parallel, start from the most recent user, etc.

enfein commented

I think this is possible to do with cipher caching.

Given there are some other protocol changes we can make, let's do everything together and target this at mieru v3.0.0 release.