0

I'm developing an Online Judge as part of my university project. Done setting up the compiler. But the problem is I want to insert all the user inputs in one queue and compile and execute them one by one. This question may seem funny too you but as a noob I don't even know what to write in google search engine. Tried many ways to search in google. Elaborative ways as I should say. Even facebook groups were no help at all.

I repeat my problem again, suppose there are 100 users submitting 100 codes at the same time. I need to put all of them in a single queue then process them one by one.

If you just tell me the name of this procedure that'll be very much helpful. I'll study the rest.

thank you. please don't get offended for such silly question.

regards!

  • 2
    Store the values in a database and have a background process query the database and process the data? – David Dec 12 '17 at 19:00
  • 2
    Done setting up the compiler for php? – Jaime Dec 12 '17 at 19:00
  • 1
    Sifar, consider @David's approach. You'd need to familiarize yourself with PDO, MySQL, and cron jobs in Linux. There's no external "queue" where you could hold your data, you need a data store, i.e. a database. – Alex Dec 12 '17 at 19:04
  • yes, with the help of shell scripting and g++, gcc compilers @Jaime – Sifat Ahmed Dec 12 '17 at 19:08
  • @David have you seen https://www.urionlinejudge.com.br/judge/en/runs/live system?? I don't know how did they do it. I want something similar. and for the database one, I need to run a background process to check if anyone has given any input. Is it the optimal solution?? I did think about it before. But didn't seem much convincing though I have less idea. – Sifat Ahmed Dec 12 '17 at 19:12
  • `Queue` is the operative word. See also: https://stackoverflow.com/questions/11357187/php-how-do-i-implement-queue-processing-in-php – Progrock Dec 12 '17 at 19:13
  • @SifatAhmed: No, I'm not familiar with that system. If you want to know implementation details of that system, you'll need to ask them. *"But didn't seem much convincing though I have less idea."* - That's not really an answerable question. Are there potential problems you might encounter in developing your system based on information we don't have in this question? Ya, probably. But *in general* if you're asking how to record user submissions, a database seems like a reasonable first pass at the problem. – David Dec 12 '17 at 19:16
  • @David, so, if 100 user submits their code then I need to store them in database at first then compile and run them and send the results back to the users? In this manner I need to check the database all the time. but what what I want is keep those input codes in a temporary place, execute them in first come first serve manner with some threading applied then write the outcomes in the database. – Sifat Ahmed Dec 12 '17 at 19:20
  • @SifatAhmed: If you expect the "process" for any given user to potentially take more than a brief moment, then you don't want to do it live in a website. You can notify users of their results in a variety of ways. Display a message on the website the next time they load the page, send them an email, etc. A web application is not a good place for long-running background threads. Just use the web application to present the user interface. A background process can much more reliably handling the background processing. – David Dec 12 '17 at 19:23
  • @SifatAhmed Perhaps you might consider something like Redis or Couchbase for storing your data blobs? When the input is submitted, you can check whether enough users have already sent their submissions, and only then start processing them. Then have your server broadcast changes on a websocket, and your front-end listen to those updates, and re-render the UI accordingly? It'd be easier with a framework like [Laravel](https://laravel.com/docs/5.5/broadcasting) and [Vue](https://vuejs.org/). – Alex Dec 12 '17 at 19:30

1 Answers1

0
  1. Create a database (mysql or whatsoever) and a table that meets the data you need to store.
  2. For each form submit, store the data in the table.
  3. Run a cronjob task and fetch rows from the database. Mark these rows as "processing" just once you fetch them and "completed" once you process them.
    1. Voila!
Darker
  • 83
  • 2
  • 8