3

I'm trying to develop a web app with Django that would let users to run C programs on a server. The steps that I'm currently following are:

  • User types in the code and clicks on the 'Submit' button
  • Code goes to server; server puts it in a temporary file
  • Code is compiled using a call to subprocess.Popen()
  • Output (error) is returned back to the browser

This is a simple model, and working fine. However, I'm not sure if this is the "perfect" model, and I've some concerns about it's scalability (and security):

  1. Would it be better to use threading?
  2. Would it be better to use multiprocessing?
  3. Fork bomb issue was pointed out in a related question raised by myself here -- how to deal with that? Would the following settings in apache2.conf be able to handle such situations?

    # prefork MPM
    # StartServers: number of server processes to start
    # MinSpareServers: minimum number of server processes which are kept spare
    # MaxSpareServers: maximum number of server processes which are kept spare
    # MaxClients: maximum number of server processes allowed to start
    # MaxRequestsPerChild: maximum number of requests a server process serves

I'm considering the case when say, 5, 15, 50 users would try to run their code in parallel. Also, for the time being am assuming that no malicious code would be written.

Just to mention, mod_wsgi and mpm-prefork with Apache2 are being used.

Thanks for all your suggestions!

1
  • Indepedent of what you are doing, using embedded mode of mod_wsgi and prefork MPM is a bad idea. Go read blog.dscpl.com.au/2009/03/… Commented Sep 1, 2011 at 9:53

1 Answer 1

3

Maybe Celery project will help you.

Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.

The execution units, called tasks, are executed concurrently on a single or more worker servers using multiprocessing, Eventlet, or gevent. Tasks can execute asynchronously (in the background) or synchronously (wait until ready).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I'm using celery. However, not sure about performance related things.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.