Giter VIP home page Giter VIP logo

yufccode / load-balanced-online-oj-system Goto Github PK

View Code? Open in Web Editor NEW
119.0 9.0 13.0 23.19 MB

Implement an online programming system similar to LeetCode. Multiple compilation service hosts (CR hosts) can be deployed in the background, and then oj_server service will load balance a large number of submitted requests to each CR host through algorithms. If a CR host crashes in the background, oj_server can also recognize correctly.

C++ 92.76% Makefile 0.28% HTML 6.97%
load-balance online-judge-engine operating-system socket-programming webserver

load-balanced-online-oj-system's Introduction

Load-balanced-online-OJ-system



Load-balanced-online-OJ-system

The detailed code details of the project implementation are shown in the following files.

1. Project Description

Implement an online programming system similar to leetcode.

Multiple compilation service hosts (cr hosts) can be deployed in the background, and then the oj_server service will load-balancedly deploy a large number of submission requests to each cr host through algorithms. If the cr host in the background hangs up, oj_server can also correctly identify it.

The architecture is as follows.

2. Technologies and development environments used

Technology used

C++STL, Boost quasi-standard library, cpp-httplib third-party open source network library, ctemplate third-party open source front-end web page rendering library, jsoncpp third-party serialization and deserialization library, load balancing design, distributed system, multi-process and multi-threading Control, Mysql C Connect, Ace front-end editor, html/css/js/jquery/ajax

Development Environment

  • centos server
  • vscode

3. Project operation display

3.1 Page display

Homepage.

题目列表(可继续增加题目)

Answer interface.

答案/编译出现错误样例。

代码补全。

3.2 Backend display

Compile service backend interface

oj service backend.

Submit multiple times instantly to check the load balancing situation.

It can be seen that oj_server can achieve load balancing very well, and every background host can get requests.

4. How to download and run

4.1 run

clone the repo。

git clone https://github.com/Yufccode/Load-balanced-online-OJ-system.git

enter the repo。

cd Load-balanced-online-OJ-system;
cd online_judge

Compile to generate executable。

make

At this time, there is already an executable in the oj_server directory and compile_server directory respectively.。

Then start compile_server under three command lines, and then start oj_server under the fourth command line.

# Three command lines execute these three respectively
./compile_server 8081
./compile_server 8082
./compile_server 8083
export LD\_LIBRARY\_PATH=$LD\_LIBRARY\_PATH:/usr/local/lib # set the env
./oj_server # The fourth command line executes this command

Just browse to port 8080 in your browser.

If it is a cloud server, remember to open the firewall, otherwise it will not be accessible.

4.2 Add/adjust the host of the cr service or deploy the cr service to the remote end

The default is now three cr service hosts. You can add it and just modify the configuration file.

./oj_server/conf/service_machine.conf
127.0.0.1:8081
127.0.0.1:8082
127.0.0.1:8083

Just change the configuration inside. It's very simple. If you want to deploy to the remote end, just change it to your remote IP. Then if you want to add a host, just add it directly later.

4.3 publish project

Just call the makefile file in the top directory.

make

After make, there will be a make_output directory, which contains the content to be published.

5. How to add questions

So the question information is stored in this directory.

./oj_server/questions

The directory structure is shown below.

.
├── 1
│   ├── desc.txt
│   ├── header.cpp
│   └── tail.cpp
├── 2
│   ├── desc.txt
│   ├── header.cpp
│   └── tail.cpp
├── 3
│   ├── desc.txt
│   ├── header.cpp
│   └── tail.cpp
├── 4
│   ├── desc.txt
│   ├── header.cpp
│   └── tail.cpp
└── question.list

4 directories, 13 files

question.list format.

1 字符串长度 简单 1 30000
2 判断回文数 中等 1 30000
3 求最大值 简单 1 30000
4 N皇后 困难 1 30000

Each column is the question list, question name, difficulty, CPU running time limit, and memory usage limit.

Each folder named with a number represents detailed information for each topic.

desc.txt is the topic description and some detailed information.

header.cpp is the code snippet displayed to the user.

tail.cpp is the code snippet used by the backend for testing.

To add questions, just follow the above format.

load-balanced-online-oj-system's People

Contributors

ffengc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

load-balanced-online-oj-system's Issues

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.