⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’
Excalidraw Data
Text Elements
client
Coder service
primary DB
execute code w.r.t testcase
problems
submissions
GET v1/programs GET v1/problem/id POST v1/problem?id/solution GET v1/leaderboard/competitionId GET v1/check/id
Coder service
primary DB
execute code w.r.t testcase
problems
GET v1/programs GET v1/problem/id POST v1/problem?id/submission GET v1/leaderboard/competitionId GET v1/check/id
client
VM / serverless program(lamda)
docker Container
python runtime service
java runtime service
jscript
kotlin
submissions
seperate env used for code execution to avoid main server failure in case of any security issue
Security Docker for isolation read only files allowed to be accessed by executing code Docker can be created with CPU and memory bound to avoid overutilisation of sesources VPC for network control defined timeout for long running code Block system calls
How do we make leaderboard more efficient?
Coder service
primary DB
execute code w.r.t testcase
problems
GET v1/programs GET v1/problem/id POST v1/problem?id/submission GET v1/leaderboard/competitionId GET v1/check/id
client
VM / serverless program(lamda)
docker Container
kotlin
python runtime service
java runtime service
jscript
submissions
seperate env used for code execution to avoid main server failure in case of any security issue
redis cache
Updates aren’t truly real-time, and there’s still polling involved, which isn’t ideal for live updates. There’s also a potential for race conditions if the cache update frequency is too low
How would the system scale to support competitions with 100,000 users?
Coder service
primary DB
execute code w.r.t testcase
problems
GET v1/programs GET v1/problem/id POST v1/problem?id/submission GET v1/leaderboard/competitionId
client
VM / serverless program(lamda)
docker Container
kotlin
python runtime service
java runtime service
jscript
submissions
seperate env used for code execution to avoid main server failure in case of any security issue
redis cache
queue
worker
worker gets the results, it will notify the App Server so it can update both the database and the cache.
leaderboard sorted set
Monaco IDE
Queue buffer submissions during peak times and ensure that we don’t overwhelm the containers. We can use a managed queue service like SQS to handle this for us.
We introduce a new endpoint, say GET /check/:id, that is polled every second by the client to check if the submission has been processed