| 1 | # GarageMQ [](https://travis-ci.org/valinurovam/garagemq) [](https://coveralls.io/github/valinurovam/garagemq) [](https://goreportcard.com/report/github.com/valinurovam/garagemq) |
| 2 | |
| 3 | GarageMQ is a message broker that implement the Advanced Message Queuing Protocol (AMQP). Compatible with any AMQP or RabbitMQ clients (tested streadway/amqp and php-amqp lib) |
| 4 | |
| 5 | #### Table of Contents |
| 6 | - [Goals of this project](#goals-of-this-project) |
| 7 | - [Demo](#demo) |
| 8 | - [Installation and Building](#installation-and-building) |
| 9 | - [Docker](#docker) |
| 10 | - [Go get](#go-get) |
| 11 | - [Execution flags](#execution-flags) |
| 12 | - [Default config params](#default-config-params) |
| 13 | - [Performance tests](#performance-tests) |
| 14 | - [Persistent messages](#persistent-messages) |
| 15 | - [Transient messages](#transient-messages) |
| 16 | - [Internals](#internals) |
| 17 | - [Backend for durable entities](#backend-for-durable-entities) |
| 18 | - [QOS](#qos) |
| 19 | - [Admin server](#admin-server) |
| 20 | - [TODO](#todo) |
| 21 | - [Contribution](#contribution) |
| 22 | |
| 23 | ## Goals of this project |
| 24 | |
| 25 | - Have fun and learn a lon |
| 26 | - Implement AMQP message broker in Go |
| 27 | - Make protocol compatible with RabbitMQ and standard AMQP 0-9-1. |
| 28 | |
| 29 | |
| 30 | ## Demo |
| 31 | Simple demo server on Digital Ocean, ```2 GB Memory / 25 GB Disk / FRA1 - Ubuntu Docker 17.12.0~ce on 16.04``` |
| 32 | |
| 33 | | Server | Port | Admin port | Login | Password | Virtual Host | |
| 34 | |:-------------:|:----:|:----------:|:-----:|:--------:|:------------:| |
| 35 | | 46.101.117.78 | 5672 | 15672 | guest | guest | / | |
| 36 | |
| 37 | - [AdminServer - http://46.101.117.78:15672/](http://46.101.117.78:15672/) |
| 38 | - Connect uri - ```amqp://guest:[email protected]:5672``` |
| 39 | |
| 40 | ## Installation and Building |
| 41 | ### Docker |
| 42 | |
| 43 | The quick way to start with GarageMQ is by using `docker`. You can build it by your own or pull from docker-hub |
| 44 | ```shell |
| 45 | docker pull amplitudo/garagemq |
| 46 | docker run --name garagemq -p 5672:5672 -p 15672:15672 amplitudo/garagemq |
| 47 | ``` |
| 48 | or |
| 49 | |
| 50 | ```shell |
| 51 | go get -u github.com/valinurovam/garagemq/... |
| 52 | cd $GOPATH/src/github.com/valinurovam/garagemq |
| 53 | docker build -t garagemq . |
| 54 | docker run --name garagemq -p 5672:5672 -p 15672:15672 garagemq |
| 55 | |
| 56 | ``` |
| 57 | ### Go get |
| 58 | You can also use [go get](https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies): ```go get -u github.com/valinurovam/garagemq/...``` |
| 59 | ```shell |
| 60 | go get -u github.com/valinurovam/garagemq/... |
| 61 | cd $GOPATH/src/github.com/valinurovam/garagemq |
| 62 | make build.all && make run |
| 63 | ``` |
| 64 | ### Execution flags |
| 65 | | Flag | Default | Description | ENV | |
| 66 | | :--- | :--- | :--- | :--- | |
| 67 | | --config | [default config](#default-config-params) | Config path | GMQ_CONFIG | |
| 68 | | --log-file | stdout | Log file path or `stdout`, `stderr`| GMQ_LOG_FILE | |
| 69 | | --log-level | info | Logger level | GMQ_LOG_LEVEL | |
| 70 | | --hprof | false | Enable or disable [hprof profiler](https://golang.org/pkg/net/http/pprof/#pkg-overview) | GMQ_HPROF | |
| 71 | | --hprof-host | 0.0.0.0 | Profiler host | GMQ_HPROF_HOST | |
| 72 | | --hprof-port | 8080 | Profiler port | GMQ_HPROF_PORT | |
| 73 | |
| 74 | ### Default config params |
| 75 | ```yaml |
| 76 | # Proto name to implement (amqp-rabbit or amqp-0-9-1) |
| 77 | proto: amqp-rabbit |
| 78 | # User list |
| 79 | users: |
| 80 | - username: guest |
| 81 | password: 084e0343a0486ff05530df6c705c8bb4 # guest md5 |
| 82 | # Server TCP settings |
| 83 | tcp: |
| 84 | ip: 0.0.0.0 |
| 85 | port: 5672 |
| 86 | nodelay: false |
| 87 | readBufSize: 196608 |
| 88 | writeBufSize: 196608 |
| 89 | # Admin-server settings |
| 90 | admin: |
| 91 | ip: 0.0.0.0 |
| 92 | port: 15672 |
| 93 | queue: |
| 94 | shardSize: 8192 |
| 95 | maxMessagesInRam: 131072 |
| 96 | # DB settings |
| 97 | db: |
| 98 | # default path |
| 99 | defaultPath: db |
| 100 | # backend engine (badger or buntdb) |
| 101 | engine: badger |
| 102 | # Default virtual host path |
| 103 | vhost: |
| 104 | defaultPath: / |
| 105 | # Security check rule (md5 or bcrypt) |
| 106 | security: |
| 107 | passwordCheck: md5 |
| 108 | connection: |
| 109 | channelsMax: 4096 |
| 110 | frameMaxSize: 65536 |
| 111 | ``` |
| 112 | |
| 113 | ## Performance tests |
| 114 | |
| 115 | Performance tests with load testing tool https://github.com/rabbitmq/rabbitmq-perf-test on test-machine: |
| 116 | ``` |
| 117 | MacBook Pro (15-inch, 2016) |
| 118 | Processor 2,6 GHz Intel Core i7 |
| 119 | Memory 16 GB 2133 MHz LPDDR3 |
| 120 | ``` |
| 121 | ### Persistent messages |
| 122 | ```shell |
| 123 | ./bin/runjava com.rabbitmq.perf.PerfTest --exchange test -uri amqp://guest:guest@localhost:5672 --queue test --consumers 10 --producers 5 --qos 100 -flag persistent |
| 124 | ... |
| 125 | ... |
| 126 | id: test-235131-686, sending rate avg: 53577 msg/s |
| 127 | id: test-235131-686, receiving rate avg: 51941 msg/s |
| 128 | ``` |
| 129 | ### Transient messages |
| 130 | ```shell |
| 131 | ./bin/runjava com.rabbitmq.perf.PerfTest --exchange test -uri amqp://guest:guest@localhost:5672 --queue test --consumers 10 --producers 5 --qos 100 |
| 132 | ... |
| 133 | ... |
| 134 | id: test-235231-085, sending rate avg: 71247 msg/s |
| 135 | id: test-235231-085, receiving rate avg: 69009 msg/s |
| 136 | ``` |
| 137 | |
| 138 | ## Internals |
| 139 | |
| 140 | ### Backend for durable entities |
| 141 | Database backend is changeable through config `db.engine` |
| 142 | ``` |
| 143 | db: |
| 144 | defaultPath: db |
| 145 | engine: badger |
| 146 | ``` |
| 147 | ``` |
| 148 | db: |
| 149 | defaultPath: db |
| 150 | engine: buntdb |
| 151 | ``` |
| 152 | - Badger https://github.com/dgraph-io/badger |
| 153 | - BuntDB https://github.com/tidwall/buntdb |
| 154 | |
| 155 | ### QOS |
| 156 | |
| 157 | `basic.qos` method implemented for standard AMQP and RabbitMQ mode. It means that by default qos applies for connection(global=true) or channel(global=false). |
| 158 | RabbitMQ Qos means for channel(global=true) or each new consumer(global=false). |
| 159 | |
| 160 | ### Admin server |
| 161 | |
| 162 | The administration server is available at standard `:15672` port and is `read only mode` at the moment. Main page above, and [more screenshots](/readme) at /readme folder |
| 163 | |
| 164 |  |
| 165 | |
| 166 | ## TODO |
| 167 | - [ ] Optimize binds |
| 168 | - [ ] Replication and clusterization |
| 169 | - [ ] Own backend for durable entities and persistent messages |
| 170 | - [ ] Migrate to message reference counting |
| 171 | |
| 172 | ## Contribution |
| 173 | Contribution of any kind is always welcome and appreciated. Contribution Guidelines in WIP |