Search code examples
djangopython-2.7django-rest-frameworkpython-multithreadingflask-restful

Django: How to mention number of process? like how it is done with Flaks


I am trying to create a simple Fibonacci web service with * Django and * Flask

I am using djangorestframework and flask_restful I am doing this to make some comparison.

with Flask I am able to specify the number of process or to use threading etc. with Api in flask_restful

from flask import Flask, request, Response, jsonify
from flask_restful import abort, Resource, Api, reqparse
api = Api(app)
api.add_resource(Test, '/test/')

app.run(port=1234, host='0.0.0.0', threaded=True) #processes=50)

My question, how to specify the same in django rest framework? From the docs I am not able to find a straight forward answer, yet..


Solution

  • That's because it's two different matters. Django only provides a development server which obviously is for development and single thread/process.

    If you want to tune the number of process, you'll need to run the Django project through gunicorn / uwsgi / mod_wsgi / ..., each of those lets you tune the process / threads.