Tuesday, October 26, 2010

Running large models using a web interface

For a project I am considering a fairly large GAMS models where we want end-users to run certain scenarios. Of course there must be HTML GUI to allow the user to specify the input for each scenario to run. That is fairly standard stuff – once you know what type of parameters you want to expose to the user to change. The bigger issue is that the model is too large to run immediately if the user presses the Submit button. Rather we need to create a small queueing mechanism where jobs are waiting to run. After the model has been solved the user can inspect the results.
Running background jobs from a web-server environment is a little bit more exotic, although other examples exist (see e.g. NEOS and this effort). For this project we use a Windows IIS web server with PHP.

Architecture


A background solve process can look like:
  1. If background processes are already running, stop
  2. Start a background process as follows:
  3. While there are waiting jobs
    1. select a job where status=waiting
    2. set status=running
    3. solve model
    4. store results
    5. set status=solved
We run this thing after every INSERT in the job table.
Actually we can have several of those processes if the server is beefy enough to allow for parallel solution of different models. This does not only depends on the number of cores available but also memory considerations play a role. Essentially line 1 becomes:
  1. If number of background processes ≥ maxnumproc, stop

No comments:

Post a Comment