Skip to content

Instantly share code, notes, and snippets.

@pzread pzread/
Last active Aug 29, 2015

What would you like to do?
Judge Sketch


The package is compressed in tar.xz format without top directory.


  pkgid string      //Add by add_pkg API
  apiid string      //Add by add_pkg API, owner id
  when int64        //Add by add_pkg API
  expire int64      //Unix timestamp


  1. meta is stored at local redis, list of who has this package is stored at cluster redis.
  2. When need to transport package from other node, use SRANDMEMBER to pick up a node which has the package.
  3. If node is requested to transport a package but find out the package is missed, update the cluster redis and return 404 error.


  1. Use redis as DB.
  2. Need root to run judge, but judge server don't.
  3. All nodes are in one VPN, use nginx's load balancers to proxy outside request to node.
  4. Node server bind on VPN IP.


  1. Keep all things simple.
  2. Every node has it's individual redis db to store local data.
  3. There is a redis cluster for communicating with other servers without losing consistency. (for now, because the redis cluster is still in alpha, use a signle redis server instead)
  4. HTTPS (REST?) API for client.
  5. All data is named as "Package", each package has a meta.json to contain metadata. After package has been loaded, redis cluster will store metadata, the key is sha256(UUID)
  6. API Key for quota limit and security. Split APIs into internal API and external API, internal API only can be used inside the VPN.
  7. URL of external API starts with /api, URL of internal API starts with /capi.
  8. redis journal is the truth, if any node find anything doesn't fit the redis journal, try to fix itself first.
  9. Same package can be used by many API, API should first check if all fields it needs exists.
  10. The scale of performance is big, the network bandwidth, dispatch challenge tasks may be main problems.
  11. Transport large files by nginx's X-Accel-Redirect to reduce the I/O loading of maratini.
  12. For any special access limit, define in meta.json and modules can check the permission themself.
  13. Space of storage may be not a big problem except of running on temporarily cloud machine.
  14. If there is a node whom over half of nodes in cluster can't contact, es ist tot.
  15. Schedule the transport request to prevent from duplicate transport and do more optimization.



###add_pkg Uplaod compressed package.

#####Parameter /add_pkg

  • data: Package binary data


  • pkgid: UUID for package

###get_pkg Download compressed package. Only allow the uploader of this package to download.

#####Parameter /get_pkg/:pkgid

  • pkgid: Package ID


  • data: Compressed package binary

###get_state Get cluster and node state

#####Parameter /get_state


  • node: states of all nodes


###trans_pkg Transport compressed package.

#####Parameter /trans_pkg/:pkgid

  • pkgid: Package ID


  • data: Compressed package binary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.