Giter Site home page Giter Site logo

benjamesbabala / viabtc_exchange_server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from viabtc/viabtc_exchange_server

0.0 2.0 0.0 689 KB

A high performance and real time quotation push trade engine.

License: MIT License

C 97.73% C++ 0.85% Makefile 0.97% Shell 0.29% Python 0.17%

viabtc_exchange_server's Introduction

ViaBTC Exchange Server

ViaBTC Exchange Server is a high performance trade backend for exchanges like digital currency exchange. It support up to 10000 trades every second. It support push user data and market data in real time thought websocket.

Architecture

Architecture

This project is the server part in this picture.

code structure

Require system

  • MySQL: save oper log, save user balance history, order history, trade history.

  • Redis: a redis sentinel group, save market data.

  • Kafka: a message system.

Base library

  • network: a event base and high performance network programming library, easily supoort 1000K TCP connections. Include TCP/UDP/UNIX SOCKET server and client implementation, a simple timer, state machine, thread pool.

  • utils: some basic library. Include log, config parse, some data structure, http/websocket/rpc server implementation.

Modules

  • matchengine: the most important part, it reord user balance, execute user order. It is a in memory database, save oper log in MySQL, redo the oper log when start. It also write user history into MySQL, push balance and order and deal message to kafka.

  • marketprice: read message from kafka, generage k line data.

  • readhistory: read history data from MySQL.

  • accesshttp: support a simple HTTP interface and hide complexity for upper layer.

  • accwssws: a websocket server, support user data and market data query and push. You need nginx in front to support wss.

  • alertcenter: a simple server write FATAL level log to redis list, so we can send alert emails.

Compile and Install

operating system

Ubuntu 14.04 or Ubuntu 16.04. Not test on other system

Requirements

See requirements. Install those system or library.

You MUST use the depends/hiredis to install the hiredis library. Or it may not compatibility.

Compile order

Compile network and utils first. The rest all are independent.

Deploy

The matchengine and marketprice and alertcenter is a signal instance, the readhistory and accesshttp and accwssws can have multi instance work with loadbalance.

Every instance better not install on same machine.

Every process runing in deamon and start with a watchdog process, if crash, it will autoly restart in 1s.

The best practice of deploy the instance is in following directory structure:

matchengine
|---bin
|   |---matchengine.exe
|---log
|   |---matchengine.log
|---conf
|   |---config.json
|---shell
|   |---restart.sh
|   |---check_alive.sh

API

There are HTTP Protocl and Websocket Protocl documents. But it is in Chinese, I may translate it into English in the future.

viabtc_exchange_server's People

Contributors

haipome avatar pplorins avatar

Watchers

James Cloos 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.