title: django slow POST response
body: <p>I've been trying to learn python and django by creating a server on an raspberry pi 3  to accept data from some IoT projects around the house.</p>
  
  <p>I have set up the server and successfully managed to POST data to a url. However, I'm seeing that that the POST request takes about 1s. This is far too slow if I want several IoT devices feeding data back to the pi.</p>
  
  <pre><code>@csrf_exempt
  def update(request):
  
    if request.method == "POST":
      key = request.POST.get("key", "")
  
      if key == settings.API_KEY:
          deviceID = request.POST.get("id", "")
          format = request.POST.get("format", "")
          datatype = request.POST.get("datatype", "")
          data = request.POST.get("data", "")
  
          fields = [format,datatype,data]
  
          WriteFields(deviceID,fields)
          return JsonResponse({"result": "received"})
      else:
          return JsonResponse({"error": "invalid_key"})
  
  return JsonResponse({"error": "no_post"})
  </code></pre>
  
  <p>I ran a quick script to test the POST rate</p>
  
  <pre><code>import requests
  
  for i in range(100):
      r = requests.post("http://heimdall:8000/sensors/update/", data={'key': 'testkey', 'id': '123456', 'format': 'temp', 'datatype': 'c', 'data': '12'})
      print(r.status_code, r.reason)
  </code></pre>
  
  <p>The timestamps in the django terminal were showing the response about every 1s. To eliminate the pi being the bottle-neck I ran the same django project on my i3 based Plex media server and I get similar results.<br>
  I've also tested sending POST requests using CURL from windows cmd line and see the same response time. Is this a fundamental limit of POST? Or is the problem likely to be in my project somewhere?</p>
  
  <p><strong>UPDATE</strong><br>
  I've removed most of the code from the Update function and re-run</p>
  
  <pre><code>@csrf_exempt
  def update(request):
      if request.method == "POST":
          key = request.POST.get("key", "")
      return JsonResponse({"test": "test"})
  </code></pre>
  
  <p>but the response rate is still around 1s.<br>
  I've also noted the comments about using <code>aiohttp</code>, I will investigate this next.<br>
  I've tried setting <code>DEBUG = False</code> in settings.py with no change.</p>
  
  <p><strong>UPDATE2</strong><br>
  Interestingly actually running the request on my nodemcu esp8266 IoT device I don't see this delay... the serial output from the Arduino console DOESN'T pause for 1s and it still successfully reads the response from the server.</p>