Giter VIP home page Giter VIP logo

better-mosquitto's Introduction

better-mosquitto

Because there are several design in mosquitto are not good enough, so i decide to change it as to train my c.

Feature

TODO

  • custom event loop
  • better datastructure
  • persist/backup
  • signal handling
  • a web interface based on go(and self web framework)

log

  • 2014.3.31 add libevent support done
  • 2014.3.30 try to add libevent support
  • 2014.3.27 add kqueue support

架构

旧的逻辑,但就消息处理的角度来看,基本上是依靠select的轮训。

  • step1 问一次所有监听的socket,有没内容可以处理。
  • step2,问完后,就把发过来的消息塞订阅了对应话题的客户端自己维护的队列里面。
  • step3,轮训每个客户端,把他们消息队列上面的消息发送出去。然后又来一次新的select轮训。

总的来说,整个程序都是串行起来运行的,逻辑较简单。

[    ] ----->client
    \
     \  --->pub
      \
    [                ]  ---->lots of listen sockets      *step1
      \     \      \
        \     \     \
       [  ]   [  ]   [  ]   --->contexts->msgs array    *step2

             ****              *step3

Known Weakness

  • select event loop
  • most data structure is linked list
    • cost O(n)
  • 内存分配策略简单,来一个生成一个,存在优化空间。
    • 比如改用初始2倍,到达一定数量后,以后每次改用增加额定数量的算法
  • 内存占用过大
    • 没有使用数据库,数据都堆在内存里面,可能无法应付大数据量
  • 改为单线程版本,降低锁开销,目前锁开销还是非常大的。目测可以改为单进程版本,类似redis,精心维护的话应该能达到不错的效果
  • 网络数据读写使用一次尽量多读的方式,避免多次进入系统调用;
  • 内存操作优化。不free,留着下次用;
  • 考虑使用spwan-fcgi的形式或者内置一次启动多个实例监听同一个端口。这样能更好的发挥机器性能,达到更高的性能;

better-mosquitto's People

Contributors

123daoxyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.