I have the urge to write an open source mqtt server

Recently, I did a little research on the mqtt server mosquitto and the nats server gnatsd (three or four days). The performance of gnastd is very good, but the loss is that there is no persistence and non-standard protocols, which leads to weak client support. The performance of mosquitto is too poor, and the code is extremely lacking in optimization. , but because it wins the mqtt standard, the client has an advantage.
I don't want to change mosquitto directly. Although the C language is very fast, it is too inefficient to write, and there is no coroutine. It is not easy to write high-concurrency and high-performance programs that support multi-core CPUs. Although there is an open source state threads library that simulates coroutines library, but not easy to use.
And gnatsd is written in golang, which I like. It naturally supports high concurrency, and even rarely uses chan for high performance. For my performance control, I really like it. And the nats protocol is a bit like a simplified version of mqtt that only supports qos0.
Although there is also a golang version of the mqtt server on github, the one that started the most is no longer updated, but someone else forked a new one for maintenance. In terms of performance, my intuition should not be as good as gnatsd.
So I came up with the idea of ​​modifying the mqtt server based on qnatsd. Although I felt itching to start the action after I had this idea, I really didn't have time. I was working for myself all the time. We will talk about it after the project is launched.
The first goal of the plan is to change gnatsd to mqtt that supports qos0, or not to support persistence, and then add a custom authentication system and prevent the same user from logging in repeatedly. In this way, I can directly utilize mqtt clients in a large number of different languages, such as my most desired swift client.

I went through the golang version of the mqtt server again and found this:
surgemq
is the project with the most stars mentioned above but has not been maintained and updated for a long time.
There is also this volantmq , modified from surgemq, which is still being updated recently.

I flipped through the topic code in surgemq. The data structure used by gnatsd analyzed in my previous article is similar, and the algorithm principle is the same. And the performance of this project seems to be very good. Ringbuf is also used in it. In the future, you can merge this project with gnatsd and modify it into your own mqtt server.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325671337&siteId=291194637