开发者

Web app with Django for remote code execution

开发者 https://www.devze.com 2023-04-01 00:28 出处:网络
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:

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!


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消