moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 508 forks source link

Implement authentication and authorization on separate threads #600

Closed manikawnth closed 7 years ago

manikawnth commented 7 years ago

Since authentication happens on every connect and auth Pub/Sub happens on every message of a topic, is it possible to optionally implement those functionalities on a separate threads. It would be helpful to implement strong CPU intensive hashing mechanisms while authenticating.

  1. Offload the auth logic on to a separate thread
  2. Use web-worker threads instead of separate node processes (Ref: https://github.com/audreyt/node-webworker-threads)
  3. Once the web-worker returns, call the callback with true/false.
mcollina commented 7 years ago

@manikawnth nothing prevent you to do any of that. Have you tried benchmarking it?

manikawnth commented 7 years ago

Hi Matteo, you can ignore the request. It's not giving enough benefits. Threading / separate process have their own communication overheads. Hashing is just a 1 second blip which happens only during authentication. So this is not a big issue.