Help Needed: Django Server For High Frequent Requests

76 views
Skip to first unread message

Xiao Bo

unread,
Dec 9, 2016, 3:15:50 PM12/9/16
to Django users

I'm building a Django server for data collection. However, the program seems not capable when the sensing network expands. As time goes on, the program doesn't even enter the code piece and report broken pipe/connection reset by peer/too many open files errors:

Exception happened during processing of request from ('172.58.139.243', 30713)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
  File "/usr/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 126, in __init__
  File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
  File "/usr/lib/python2.7/SocketServer.py", line 710, in finish
  File "/usr/lib/python2.7/socket.py", line 279, in close
  File "/usr/lib/python2.7/socket.py", line 303, in flush
error: [Errno 32] Broken pipe

[08/Dec/2016 17:46:47] "POST /Update_Data/ HTTP/1.1" 500 39484
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 217, in write
  File "/usr/lib/python2.7/socket.py", line 324, in write
  File "/usr/lib/python2.7/socket.py", line 303, in flush
error: [Errno 104] Connection reset by peer

File "/usr/lib/python2.7/random.py", line 810, in random
OSError: [Errno 24] Too many open files

I checked the open files and it seems like the socket files are never closed. The list is full of items like the followings:

python    30404 30522     ubuntu  732u     IPv4 2437194784      0t0        TCP 192.168.100.2:9003->172.58.137.113:18538 (ESTABLISHED)
python    30404 30522     ubuntu  733u     IPv4 2437194788      0t0        TCP 192.168.100.2:9003->172.58.137.113:55661 (ESTABLISHED)
python    30404 30522     ubuntu  734u     IPv4 2437194792      0t0        TCP 192.168.100.2:9003->172.58.137.113:42461 (ESTABLISHED)
python    30404 30522     ubuntu  735u     IPv4 2437194793      0t0        TCP 192.168.100.2:9003->172.58.137.113:40438 (ESTABLISHED)
python    30404 30522     ubuntu  736u     IPv4 2437194797      0t0        TCP 192.168.100.2:9003->172.58.137.113:52998 (ESTABLISHED)

Any ideas? Let me know if you need any further information.

Avraham Serour

unread,
Dec 10, 2016, 3:37:17 PM12/10/16
to django-users
are you using manage.py runserver?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/58e4d24e-ca9b-41da-8df7-3e195630b05a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xiao Bo

unread,
Dec 10, 2016, 4:38:47 PM12/10/16
to Django users
Yes, I did.

在 2016年12月10日星期六 UTC-5下午3:37:17,Avraham Serour写道:
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Avraham Serour

unread,
Dec 10, 2016, 4:43:47 PM12/10/16
to django-users
don't use runserver for production ever.


after that I suggest using nginx with uwsgi

it is also worth reading uwsgi documentation, there are a lot of options you can tweak

nginx also has some options you can tweak



To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Xiao Bo

unread,
Dec 10, 2016, 5:05:40 PM12/10/16
to Django users
Thanks!

在 2016年12月10日星期六 UTC-5下午4:43:47,Avraham Serour写道:
Reply all
Reply to author
Forward
0 new messages