forked from demerphq/relay
karlpilkington/relay
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
simple(~500 lines) socket<->socket relay that listens on unix/udp and enqueues packets into one or more workers which send them to their destination. If the remote socket is tcp then it uses TCP_CORK on one streaming tcp connection to send its data. install: $ git clone https://github.com/jackdoe/relay $ cd relay $ make $ # and then run ./bin/relay usage: relay local_socket fallback_socket worker_socket .... for exmple: relay /tmp/relay.sock udp@events-fallback.example.com:112233 \ tcp@events-0.example.com:112233 tcp@events-1.example.com:112233 listener socket can be only DGRAM udp/unix. packet \ / worker -> listener-1 packet |- relay - worker -> listener-2 packet / \ worker -> listener-3 main_thread -> foreach listener -> start one worker thread -> listen for udp sereal packet -> append sereal packet to queue for each worker worker main_loop: -> if queue is non-empty -> lock queue hijack queue (move items from queue to local storage) unlock queue -> open connection to listener -> while items in hijacked queue -> try to send top item to listener -> if it fails: write remaining items to disk goto main_loop -> if it is ok: pop item from hijacked queue. -> close connection testing: $ cd relay/test $ ./setup.sh # after testing is done you can see the results $ ./stat.sh | sort -n -t'-' -k 2 legend: po = polling sp = spinlock ga = garbage reuse ad = array data (data[65535] instead of *data) result-packet_size-relay-flags:packets_per_second ... second_best ... config: everything after first # is comment example config file (lets say /etc/relay.conf): udp@localhost:12344 #local # tcp@localhost:12345 old fallback sock/fallback.sock #fallback tcp@relay-1:1111 tcp@relay-2:1111 tcp@relay-3:1111 tcp@relay-4:1111 run app with: relay /etc/relay.conf If you want to change something for example relay-4 with relay-5, you have to edit the config file and just killall -1 relay, this will close/reopen all connections (including fallback).
About
DGRAM socket to DGRAM/STREAM relay
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published