I am currently working on project that is make a online judging system like codeforces. In this system user can submit code and the system will compile, execute, and generate output on a specific input set, and match the output with system result then give verdict.
There is a two part of that system. Front end is in PHP and the backend is in Java. I am responsible for the Java part. My first approach was to make web app. PHP send a http request to Java which file is to compile and execute. But after a certain time I realized that If I compile and execute whenever the request arrive then the system will become too slow. If there is like 300 requests at a time arrive then the system will collapse. My thought was 300 requests handle by 300 threads. But every thread doing a heavy work like compiling, executing and also checking the output.
Then I was writing a standalone java program that has a scheduler. This scheduler check the database, get the new data and compile, execute it and then update and database. This make system asynchronous.
But the problem is in second approach, PHP and Java both need to maintain same entity class(I am using Hibernate). This make the system highly coupled. Whenever PHP making a change, I have to bring change my class also.
What would be the design for this type of application.
Thank you. :)