title: Why is Celery Async Task working slower than Synchronous task?
body: <p>I'm working on a Django application that uses Celery to run some tasks Asynchronously. I tried to perform load testing and check response time using Apache Bench. From what I could figure out from the results is that response time is faster without celery async tasks.<br><br>
  I'm using: <li>Django: 2.1.0</li><li>celery: 4.2.1</li><li>Redis (Broker): 2.10.5</li><li>django-redis: 4.9.0</li></p>
  
  <p>Celery configuration in Django settings.py:<br></p>
  
  <pre><code>BROKER_URL = 'redis://127.0.0.1:6379/1'
  CELERY_RESULT_BACKEND = 'django-db' # Using django_celery_results
  CELERY_ACCEPT_CONTENT = ['application/json']
  CELERY_TASK_SERIALIZER = 'json'
  CELERY_RESULT_SERIALIZER = 'json'
  CELERY_TIMEZONE = 'Asia/Kolkata'
  </code></pre>
  
  <p>Following is my code (API exposed by my system):</p>
  
  <pre><code>class CustomerSearch(APIView):
  
      def post(self, request):
          request_dict = {# Request parameters}
          # Async Block
          response = celery_search_customer_task.delay(request_dict)
          response = response.get()
          # Synchronous Block (uncomment following to make synchronous call)
          # api_obj = ApiCall(request=request_dict)
          # response = api_obj.search_customer() # this makes an API call to 
          return Response(response)
  </code></pre>
  
  <p>And the celery task in tasks.py:</p>
  
  <pre><code>@app.task(bind=True)
  def celery_search_customer_task(self, req_data={}):
      api_obj = ApiCall(request=req_data)
      response = api_obj.search_customer() # this makes an API call to another system
      return response
  </code></pre>
  
  <p>Apache Bench command:</p>
  
  <pre><code>ab -p req_data.data -T application/x-www-form-urlencoded -l -r -n 10 -c 10 -k -H "Authorization: Token &lt;my_token&gt;" http://&lt;my_host_name&gt;/&lt;api_end_point&gt;/
  </code></pre>
  
  <p>Following is the result of ab:<br>
  <strong>Without celery Async Task</strong></p>
  
  <pre><code>Concurrency Level:      10
  Time taken for tests:   1.264 seconds
  Complete requests:      10
  Failed requests:        0
  Keep-Alive requests:    0
  Total transferred:      3960 bytes
  Total body sent:        3200
  HTML transferred:       1760 bytes
  Requests per second:    7.91 [#/sec] (mean)
  Time per request:       1264.011 [ms] (mean)
  Time per request:       126.401 [ms] (mean, across all concurrent requests)
  Transfer rate:          3.06 [Kbytes/sec] received
                          2.47 kb/s sent
                          5.53 kb/s total
  
  Connection Times (ms)
                min  mean[+/-sd] median   max
  Connect:      259  270  10.7    266     298
  Processing:   875  928  36.9    955     967
  Waiting:      875  926  35.3    950     962
  Total:       1141 1198  43.4   1224    1263
  
  Percentage of the requests served within a certain time (ms)
    50%   1224
    66%   1225
    75%   1231
    80%   1233
    90%   1263
    95%   1263
    98%   1263
    99%   1263
   100%   1263 (longest request)
  </code></pre>
  
  <p><strong>With celery Async Task</strong></p>
  
  <pre><code>Concurrency Level:      10
  Time taken for tests:   10.776 seconds
  Complete requests:      10
  Failed requests:        0
  Keep-Alive requests:    0
  Total transferred:      3960 bytes
  Total body sent:        3200
  HTML transferred:       1760 bytes
  Requests per second:    0.93 [#/sec] (mean)
  Time per request:       10775.688 [ms] (mean)
  Time per request:       1077.569 [ms] (mean, across all concurrent requests)
  Transfer rate:          0.36 [Kbytes/sec] received
                          0.29 kb/s sent
                          0.65 kb/s total
  
  Connection Times (ms)
                min  mean[+/-sd] median   max
  Connect:      259  271   9.2    268     284
  Processing:  1132 6128 4091.9   8976   10492
  Waiting:     1132 6127 4091.3   8975   10491
  Total:       1397 6399 4099.3   9244   10775
  
  Percentage of the requests served within a certain time (ms)
    50%   9244
    66%   9252
    75%  10188
    80%  10196
    90%  10775
    95%  10775
    98%  10775
    99%  10775
   100%  10775 (longest request)
  </code></pre>
  
  <p>Isn't celery async task supposed to make tasks work faster than synchronous tasks? What is it that I might be missing here? </p>
  
  <p>Any help would be appreciated. Thanks.</p>