Skip to content
/ rcee Public

A Service of Algocode - A leetcode like project to consume messages from Code-Manager Service and responsible for Executing User Codes in Secure Docker Environment, and Publish result to the Result Queue.

Notifications You must be signed in to change notification settings

Mahboob-A/rcee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

72 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


Logo

Algocode - The Leetcode for Hackers

Algocode is a DSA practice platform just like Leetcode!

Read the blog Β»

Algocode Auth Service . Code Manager Service . RCE Engine Service

General Information

Algocode is an online data structure and algorithm practice backend built in microservices architecture.

Algocode currently has three services: Algocode Auth Service . Code Manager Service . and RCE Engine Service

RCE Engine Service is responsible to execute the user submitted code in the Algocode Platform. The current RCE Engine has C++ Judge that can compile,execute and compare testcases against the output of the code execution.

RCE Engine for Java Judge and RCE Engine for Python Judge are under development.

The Code Manager service publishes the user codes in RabbitMQ instance, the RCE Engine listen to C++ queue and compiles, executes and compares the testcases with the code execution output. Once a result is produced either comparing the testcases, or any error occurred during the code execution, RCE Engine publishes the result to a unified result queue which is consumed by the Code Manager service to finally cache the result in Redis and store the result in MongoDB for persistence.

To learn more about Algocode and the architecture, please READ-THE-BLOG-URL or visit Algocode here.

NOTE

A. About the Judge

Algocode is built from scratch. No 3rd party APIs or 3rd party packages has been used to implement the Judge. It is purely a docker implementation with secure and protected environment.

B. Connectivity

The RCE Engine is completely isolated service. No API has been exposed in the RCE Engine. It is only connected through the Message Queue.

C. Documentation

As the RCE Engine does not have any API to interact with, there's no dedicated documentation page for RCE Engine. However, adequate comment has been added in the codebase.

D. Deployment

The service is deployed in AWS EC2 Ubuntu 22.04 server.

E. About Algocode

This is RCE Engine Service specific guideline.

Please visit Algocode to learn the mircroservices architecture of Algocode and more in-depth guideline how to submit a solution to Algocode platform.



Production

Production Stage RCE Engine (C++ Judge)

The Algocode RCE Engine (C++ Judge) uses the following services to serve the request during Production Stage.

a. Docker to securely execute the user submitted code
b. Portainer to manage and monitor docker container in RCE Engine
c. RabbitMQ for asynchronous message processig.
d. Django as backend. 
e. Docker to containerize the service. 

Deployment

The Code Manager Service is deployed in AWS EC2 Ubuntu 22.04 Server.



Code Execution

Overview

RCE Engine is the heart behind the Algocode platform. It executes the user submitted code that was published by Code Manager Service to a RabbitMQ instance, and finally publishes the result to a unified result queue that is consumed by the Code Manager service.

The client can not directly interact with the RCE Engine Service as RCE Engine is isolated, secure service and it is only accessible to Message Queue.

Code Execution

The C++ Judge in the RCE Engine works in sibling containers architecture. The host docker container for the RCE Engine is capable of spawning sibling containers to execute the code submitted by the user. The sibling container spawned by the host docker container is secure, non-privileged and restricted container. The sibling containers are capable of fighting any potential malicious code execution such as fork-bomb, resource exhaustion file-hijacking etc.

Please visit Online Judge, it is a PoC of the C++ Judge implemented in the RCE Engine. You will find more in-depth analytical documentation on the various state of C++ Judge in the Prototype of C++ Judge.

Prototype

A separate light-weight prototype for the C++ Judge is also available. This prototype is a PoC for the C++ Judge and easier to test and manage. It can handle API requests as well as preset question to test the PoC of C++ Judge.

Please visit the FAQ of Online Judge to learn more about the Prototype of the C++ Judge. It has more detailed and analytical comparisons between the various state of the C++ Judge.



Watch In Action

A. Long Video (Describes all the features and architecture)

  • Watch from 16:30 for code execution begin and 18:30 for code submission result.
Watch the video

B. Short Video (Only core features)

  • Watch from 09:30 for code execution begin and 11:30 for code submission result.
Watch the video

Workflow - RCE Engine

Workflow

The Code Manager Service publishes the user submitted code to C++ Queue and the RCE Engine consumes from a C++ Queue to execute the code.

Once the RCE Engine consumes from the queue, it processes the data and prepares for the code execution.

As the pre-processing is completed, the C++ Judge compiles and executes the code.

Finally, the RCE Engine compares the testcases against the code execution output, if the code execution is successful, or it processes the error occurred during the compilation or execution stage, and publishes the final result to a unified result queue.

This unified result queue is consumed by the Code Manager Service to cache the result in Redis and finally store the result in MongoDB database for persistence.



Run Locally and Contribution

Run Locally

Please fork and clone this development branch of Algocode RCE Engine (C++ Judge) Service, and follow along with the envs-examples.

cd to src and create a virtual environment. Activate the virtual environment.

Run make docker-up and the development setup will start running. Please install make in your host machine.

If you use Windows Operating System, please run the respective docker commands from the dev.yml docker compose file.

Contribution

You are always welcome to contribute to the project. Please open an issue or raise a PR on the project.



Code Submission Result Examples


Some Code Submission Result Snapshots


A. AC Solution

dd8dbfe4-621b-49f1-b3a6-7ab2a892db87

B. WA Solution

bedb4255-86c9-4417-b920-5976e6129cbb

C. Compilation Error

1c5edd39-8ccd-4e23-a61d-66ae9564ca85

D. Segmentation Fault

WhatsApp Image 2024-06-05 at 11 42 42 PM (1)

E. Memory Limit Exceed

WhatsApp Image 2024-06-05 at 11 42 03 PM (1)

F. Time Limit Exceed

WhatsApp Image 2024-06-05 at 11 42 03 PM (1)



Linux Postman C++ Java Python Django AWS Docker Bash Azure CircleCI Node.js Kafka RabbitMQ Nginx

πŸ”— Links

Email Me Twitter LinkedIn Hashnode Medium Devto LeetCode


About

A Service of Algocode - A leetcode like project to consume messages from Code-Manager Service and responsible for Executing User Codes in Secure Docker Environment, and Publish result to the Result Queue.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published