2

I have a django+mysql website on AWS.

Client send post request to website, then the website query the mysql database and return a json.

I am doing stress testing to it. I send 300 post requests simultaneously to the website and get responses correctly. But if I increase the number of post request to 400, it fails with following log.

Server side :

File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run 
self.finish_response() 
File "/usr/lib/python2.7/wsgiref/handlers.py", line 128, in    finish_response 
self.write(data) 
File "/usr/lib/python2.7/wsgiref/handlers.py", line 212, in write 
self.send_headers() 
File "/usr/lib/python2.7/wsgiref/handlers.py", line 270, in    send_headers self.send_preamble() 
File "/usr/lib/python2.7/wsgiref/handlers.py", line 191, in  send_preamble self._write('HTTP/%s %s\r\n' %  (self.http_version,self.status)) 
File "/usr/lib/python2.7/wsgiref/handlers.py", line 391, in _write  self.stdout.write(data) 
File "/usr/lib/python2.7/socket.py", line 328, in write 

self.flush() File "/usr/lib/python2.7/socket.py", line 307, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 104] Connection reset by peer

Client side:

HTTPConnectionPool(host='mywebsite.com', port=3456): Max retries exceeded with url: /project/result.json (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)

I have tuned the mysql configuration for higher max_connections and timeout but it doesn't work.

Can anyone help me to resolve the issue? Thanks.

Robinisme2
  • 21
  • 2
  • Do you run your application on AWS Elastic Beanstalk or on an AWS EC2 instance that you manage yourself? – Daniel Hepper Mar 07 '17 at 07:47
  • I run my application on AWS EC2. – Robinisme2 Mar 07 '17 at 08:14
  • Are you using the dev server that comes bundled with Django? If yes, try using a more robust http server like uwsgi or gunicorn. These allow you to run multiple processes of your application and balancing the incoming load among them. – Abhinav Mar 07 '17 at 17:28
  • Thanks @AbhinavI. Yes, I used default HTTP server bundled with Django, I am trying using uwsgi with Django. Any result will feedback. – Robinisme2 Mar 08 '17 at 06:30
  • I also face the same problem, I was using API and web server on the same port. Later on, I figured out, Django web server run on single threaded. Then I ran 2 Django application for a web app and API and problem is solved now. – Vidya Sagar May 24 '17 at 07:03

0 Answers0