Learning how to use golang as a backend server + production level backend basics (caching, ratelimiting, batch processing, reverse proxy, databases, queues, and containerization)
I'm using LLMs btw, trying to understand how everything works. I myself don't know (or have forgotten) about a lot of the imp things. So, i'll go and revise them
- Revise GoLang
- Revise Redis
- Revise Docker
- Learn how to use Nginx (Reverse Proxies)
- Learn how to use RabbitMQ
- Graceful shutdown & signal handling
- Rate limiting (token bucket, leaky bucket)
- Caching strategies
- External API failures
- GRPC
Building a competitive programming judge system:
- Accept code submissions
- Run them securely in isolated environments
- Evaluate against test cases
- Return verdicts (AC / WA / TLE / RE)
Things to ensure:
- nginx API gateway (reverse proxy, and acts as a ratelimiter too)
- Go backend saves the metadata of the submission in local postgres, and pushes the job to a queue (perhaps rabbitmq)
- The judge instance keeps pulling jobs from the queue, sets up proper constraints, and security stuff (sandbox)
- Cache for tcs maybe?
cmd/— Entry point for the API serverinternal/— Judging logic, transport handlers, and database layer
-
Phase 1 (current): Single-node async judge
-
Phase 2: Redis queue + separate workers
-
Phase 3: Multiple worker processes
-
Phase 4: Workers on multiple VMs
-
Phase 5: Autoscaling + orchestration
-
Phase 6: Result streaming + realtime updates
# Build Sandbox
```bash
docker build -f Dockerfile.sandbox -t cpp-py-sandbox .
```
# Install Dependencies
```bash
go mod tidy
```
# Run Server
```bash
go run ./cmd/server
```
# Submit C++
```bash
curl -X POST "http://127.0.0.1:4000/submit" \
-H "Content-Type: application/json" \
-d "$(jq -n \
--rawfile code solution.cpp \
'{
code: $code,
language: "cpp17",
question_id: "a"
}')"
```
# Submit Python
```bash
curl -X POST "http://127.0.0.1:4000/submit" \
-H "Content-Type: application/json" \
-d "$(jq -n \
--rawfile code solution.py \
'{
code: $code,
language: "python3",
question_id: "a"
}')"
```
# Get Result
```bash
curl "http://127.0.0.1:4000/result/1"
```