moscajs / aedes

Barebone MQTT broker that can run on any stream server, the node way
MIT License
1.79k stars 232 forks source link

Use mqtt-stack & mqtt-spec? #1

Closed 256dpi closed 9 years ago

256dpi commented 9 years ago

Hi Matteo,

Just saw that you started that project. Are you considering using the mqtt-stack and mqtt-spec stuff I started? There is not much missing, I just hadn't the time to finish it yet.

mcollina commented 9 years ago

Aedes is all about speed. So, no framework here. It is going to support MQTT and MQTT only. Similarly to Mosca, it would support some pluggability.

Regarding mqtt-spec, I plan to use it for the integration tests, probably to replace what it is in Mosca now. Il giorno dom 8 mar 2015 alle 12:38 Joël Gähwiler notifications@github.com ha scritto:

Hi Matteo,

Just saw that you started that project. Are you considering using the mqtt-stack and mqtt-spec stuff I started? There is not much missing, I just hadn't the time to finish it yet.

— Reply to this email directly or view it on GitHub https://github.com/mcollina/aedes/issues/1.

256dpi commented 9 years ago

I think it is possible to build that high-speed MQTT only broker also with mqtt-stack. Since the library is just a collection of these middlewares that provide a simple API for implementing the various MQTT features. There is even already an architecture for "plugins": https://github.com/mqttjs/mqtt-stack/blob/master/test/support/memory_backend.js. Do you think that the 2, 3 additional function calls will slow down that much? And on the other hand, making mqtt-stack faster would be also a really cool thing!

I just hopped we could spare some duplicate work. ;)

mcollina commented 9 years ago

I don't know what will slow things down. I am doing this in Benchmark-Driven-Development, adding feature and checking if I can keep the same level of performance. Normally function calls do not slow things down, but creating functions and/or objects might do. In the composability vs speed battle, here I pick speed.

This approach is paying off: Aedes performs at 70k msg/sec on iojs on my macbook pro. The worst piece of performance hack is this: https://github.com/mcollina/aedes/blob/master/lib/client.js#L51-L61. That alone gave something 20-30% of perf increase.

Aedes is the reason why I did mqtt-packet. The MQTT.js Connection object was too slow. Not having a MQTT.js Connection is like a 100% perf increase over Mosca ;).

The goal is to support the full MQTT spec anyway, and I hope to keep things very decoupled here (another Mosca mistake) so they can be reused.

256dpi commented 9 years ago

I like that approach, this kind of research is interesting to follow and already paying off: I used parts of your client implementation to replace mqtt-connection. That way mqtt-stack seems handling the bombing benchmark now well (before it just corked up :D).

On my macbook-air aedes performs with 26'000 msg/s and mqtt-stack 12'000 msg/s. However the comparison might be more true when aedes is implementing the same features.

Would be cool to compare both implementations in the future to see what things slow down and could be made better.

RangerMauve commented 9 years ago

Definitely leave room for authentication and authorization plugins of some sort, though.

mcollina commented 9 years ago

@RangerMauve @256dpi if you want to contribute, I am definitely accepting pull requests ;).