All Projects → Rabbit-OJ → Rabbit-OJ-Backend

Rabbit-OJ / Rabbit-OJ-Backend

Licence: MIT license
Using Go & MySQL & Docker & Web Socket & gRPC & Kafka & Zookeeper & Protobuf. Distributed and Scalable Open Judge System for Algorithms.

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to Rabbit-OJ-Backend

Plumber
A swiss army knife CLI tool for interacting with Kafka, RabbitMQ and other messaging systems.
Stars: ✭ 514 (+2470%)
Mutual labels:  protobuf, rabbitmq
rails-microservices-book
A guide to building distributed Ruby on Rails applications using Protocol Buffers, NATS and RabbitMQ
Stars: ✭ 23 (+15%)
Mutual labels:  protobuf, rabbitmq
gome
gome- Golang Match Engine, uses Golang for calculations, gRPC for services, ProtoBuf for data exchange, RabbitMQ for queues, and Redis for cache implementation of high-performance matching engine microservices/ gome-高性能撮合引擎微服务
Stars: ✭ 47 (+135%)
Mutual labels:  protobuf, rabbitmq
Myth
Reliable messages resolve distributed transactions
Stars: ✭ 1,470 (+7250%)
Mutual labels:  protobuf, rabbitmq
micro-service-practice
OpenStack+Docker+RestAPI+OAuth/HMAC+RabbitMQ/ZMQ+OpenResty/HAProxy/Nginx/APIGateway+Bootstrap/AngularJS+Ansible+K8S/Mesos/Marathon构建/探索微服务最佳实践。
Stars: ✭ 25 (+25%)
Mutual labels:  rabbitmq
protobuf-ts
Protobuf and RPC for TypeScript
Stars: ✭ 527 (+2535%)
Mutual labels:  protobuf
protoactor-python
Proto Actor - Ultra fast distributed actors
Stars: ✭ 78 (+290%)
Mutual labels:  protobuf
elm-protobuf
protobuf plugin for elm
Stars: ✭ 93 (+365%)
Mutual labels:  protobuf
your-connection-deserves-a-name
Examples and code to assign a name to your MongoDB, MySQL, NATS, Oracle, PostgreSQL, RabbitMQ, and redis connection.
Stars: ✭ 26 (+30%)
Mutual labels:  rabbitmq
AMQPClient.jl
A Julia AMQP (Advanced Message Queuing Protocol) / RabbitMQ Client.
Stars: ✭ 30 (+50%)
Mutual labels:  rabbitmq
yages
Yet another gRPC echo server (YAGES)
Stars: ✭ 28 (+40%)
Mutual labels:  protobuf
powerproto
🎉 An awesome version control tool for protoc and its related plugins.
Stars: ✭ 161 (+705%)
Mutual labels:  protobuf
grabbit
A lightweight transactional message bus on top of RabbitMQ
Stars: ✭ 87 (+335%)
Mutual labels:  rabbitmq
RentHouseWeb
使用 go+docker+go-micro微服务框架开发的租房网系统,符合RESTful架构风格。
Stars: ✭ 28 (+40%)
Mutual labels:  protobuf
sample-spring-cloud-stream
sample microservices communicating asynchronously using spring cloud stream, rabbitmq
Stars: ✭ 22 (+10%)
Mutual labels:  rabbitmq
scalapb-circe
Json/Protobuf convertors for ScalaPB use circe
Stars: ✭ 38 (+90%)
Mutual labels:  protobuf
api
Speechly public API definitions and generated code
Stars: ✭ 15 (-25%)
Mutual labels:  protobuf
read-protobuf
Small library to read serialized protobuf(s) directly into Pandas Dataframe
Stars: ✭ 28 (+40%)
Mutual labels:  protobuf
Bynar
Server remediation as a service
Stars: ✭ 53 (+165%)
Mutual labels:  protobuf
ProtobufDecoder
A Google Protocol Buffers (Protobuf) payload decoder/analyzer
Stars: ✭ 33 (+65%)
Mutual labels:  protobuf

Rabbit OJ’s Technical Details

🚗Technical Stacks

  • Frontend: Angular & Rxjs & Typescript
  • Backend: Go & RabbitMQ & Docker & Web Socket & MySQL & gRPC & Protobuf

We will discuss the actions after the user submit a piece of code.

🤩System Design

  • Frontend(Angular) <==> Server(GIN) <==> Message Queue(Rabbit MQ) <==> Judger

  • Judger —> (Many) Machines —> Scheduler —> Compiler —> Runner —> Callback

🚄Work Flows

  1. Frontend POST a file to the Server with its question id & language type & token, then the server will validate the request and decide if the language is supported.
  2. The server will return a unique submission id to the client and the client will establish a web socket connection to the server
  3. The server will serialize the message to the protobuf bytes and send it to the Message Queue Exchange
  4. The Message Queue Exchange will match its route and enqueue to the “judge” Queue
  5. An idle Consumer (Judger) will consume the message and decide if the language is supported.
    • If the language is not configured in the config file, nack it and re-queue the message to the queue
    • This case may happen when a new language is added to the server and the judgers are executing the rolling update action. The message is sent to an judger with old version.
    • Re-queue action will guarantee the message will be consumed correctly
  6. The judger will check if it have the right version of test case, if not, dial to server and require the latest test case with credential
    • We tag each set of test cases with “version”, if the administrator update the test cases set, it will guarantee that the judger will always use the latest test case
  7. If the language requires the code to compile first (for example: C / C++ / Java), a compiler container will be started and try to compile the code. If an error occurred, then the submission is considered to be CE
    • If the language doesn’t require a compile procedure (like Python, Node.JS), this step will be jumped
  8. Then we will start a special container built by ourselves called tester, It will run the code or binary file with special arguments
    • 🤔Time Limit: We will start a go-routine, the routine will kill the process if time limit the restriction and judge TLE
    • 🤔Space Limit: We will start a go-routine, parse the file content /proc/{pid}/stat every 100ms , If it exceed the restriction, kill the process and judge MLE
    • 🤔If the process exit unexpectedly or doesn’t return zero, the submission will be considered to be RE
  9. The test inputs are mounted to the tester container ,however, the right outputs are not. The judge process will be executed after the tester container exit. We have 3 modes to test if an output is AC or WA
    • Text Compare: Simply compare if the right output and the code’s output are equal
    • Stdout Compare: Split the output with separate chars like \n, \r, , \t. Then compare two arrays
    • Float Compare: this mode is similar with mode2. The only difference is that if abs(rightArr[i] - outputArr[i]) <= 1e-6 , the answer will be accepted.
  10. The judger will serial a result protobuf object and send it to the Message Queue
  11. The Server will consume the message, storage the status into the database, notify the client with the web socket
  12. The client received the result and re-render the page

🤔How to guarantee that a message will always be consumed?

  • If a nature disaster is happened, some messages will be lost.😖
  • If the judger is killed with #9 interrupt (FORCE EXIT), The running submission’s result will lose. We should avoid to stop the judger with this signal.😖
  • If the judger received #15 interrupt (Maybe Control-C ?), The idle machine go-routines and consumer will stop immediately (This will guarantee that no more messages will be consumed), the process will exit until all the running go-routines finish.☕️

🤔Should we be optimistic or pessimistic?

  • If we are optimistic, some “unnecessary” check procedures will be ignored, the performance will be higher, but maybe we will meet some unexpected errors in some special & extreme situations.

  • If we are pessimistic, some “unnecessary” check procedures will be performed, the performance will be lower, but when we face some special & extreme situations, we can handle these errors confidently.

  • For example:

    • Check if required test cases are valid is performed in the scheduler, should we check them again in the tester?
    • When we received #15 interrupt signal from the operating system, should we be optimistic and consider that all the running processes will finish in a short time? Or we can be pessimistic and consider that the running processes will take a long long time, we re-queue the messages to the message queue and abort all the running processes?

👻A new language can be supported by only updating the config file!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].