Giter Club home page Giter Club logo

mestrace / orderbook Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 127 KB

TradeSoft is a well-known company in the crypto market that provides powerful statistics, dashboards and metrics to their customers. As a backend software developer in TradeSoft, you were requested to develop a REST API which integrates with most famous crypto exchanges and exposes aggregated data to be visualized in the application.

Makefile 1.43% Go 91.40% Thrift 7.17%

orderbook's People

Contributors

mestrace avatar

Stargazers

 avatar

Watchers

 avatar

orderbook's Issues

[Perf-1] Improve GetExchangeOrderBookAll concurrency

Currently the performance of GetExchangeOrderBookAll is bad. Usually takes around 1 minutes to query all.

  • Setup prometheus and grafana to monitor the time consumption and QPS

Improvements

  • Concurrently query for symbols
  • Rate limit the calls to blockchain.com apis

[Perf-2] Cache symbols

Cache results for each symbol as we need to query for each symbol.

Redis

  • Cache symbol list ob:{{exchange_id}}:sl (order_book:{{exchange_id}}:symbol_list).
  • Cache symbol items ob:{{exchange_id}}:si:{{symbol}}:a/b (order_book:{{exchange_id}}:symbol_item:{{symbol}}:ask/bid)
  • Wrap OrderBookDAO with cache for query symbol list and symbol item order books.

Stretch Goal

  • Local cache, can take the cache all at once
    • an data refresher thread that does that on the background
    • consider using lockfree data structure, can benchmark if have time.
  • Should implement cache hit / miss rate #6

[Quality-3]Improve API test case coverage

Add api level integration testing for all three endpoints.

  • GetExchangeOrderBook
    • Can get 1 symbol, can filter symbol, can compute correctly
  • GetExchangeOrderBookAll
    • Can get all symbol list, can filter asks and bid, can sort
  • UpdateExchangeMetadata
    • Can process csv files
    • Returning correct error when error cases

[Quality-2] Better service observability

The default prometheus handler from hertz provides little experiences.

  • Override the prometheus handler from hertz to provide end-point name
  • Monitor the calls to external services including external apis, database and redis
  • Cache hit / miss rate.

Stretch Goal

  • Container utility (CPU, Mem) (if containerisation)
  • Infra utility (CPU, Mem) (need to customize db?)

[Quality-1] Better API error code, biz code and messages.

Currently the api is returning the raw error code from each of the packages and some dynamic error code to be used. Need to have a standardised error code system.

  • for each of the relied 3pp errors, split into 400 and 500 error codes, and use appropriate biz_code and err messages for the api.
  • use static errors to replace or wrap the dynamic errors.

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.