Giter Club home page Giter Club logo

mahboob-a / rcee Goto Github PK

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

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.

Home Page: https://github.com/Mahboob-A/online-judge

Python 86.80% Dockerfile 4.11% Shell 8.18% Makefile 0.91%
coding-challenge dsa dsa-algorithm leetcode online-judge online-judge-engine rce remote-code-execution-engine remote-code-execution-rce aws ec2 ec2-instance linux

rcee's Introduction


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


rcee's People

Contributors

mahboob-a avatar

Stargazers

 avatar

Watchers

 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.