I made some experiments. I might find socket is tricking: because I set up two sockets for different workers, then touch, uwsgi will respwan workers without stop and it will use up all the resources;
If only one socket for all workers, uwsgi can be touched gracefully. Any one has any hints on this? btw, do I need to set up two or more sockets on one server? I use 4 sockets on my server, and assign 20 workers to sockets with map-socket and each socket listens to 3000 requests. maybe i could set up one socket listening to 12000 requests? 2012/4/13 Samuel <[email protected]> > My django.ini config: > > 1 [uwsgi] >> 2 # specicy workers, please change this according to the server capacity >> 3 workers = 10 >> 4 max-requests = 300 >> 5 >> 6 #set socket listen queue to <n> (default 100, maximum is system >> dependent) >> 7 listen = 3000 >> 8 socket = :8080 >> 9 socket = :8081 >> 10 >> 11 map-socket = 0:1,2,3,4,5 >> 12 map-socket = 1:6,7,8,9,10 >> 13 # set close-on-exec flag on the uWSGI socket. This will avoid >> external processes generated in a request to inherit the socket file >> descriptor.. >> 14 close-on-exec = true >> 15 >> 16 # change to django project directory >> 17 >> 18 # at the root of uwsgi >> 19 chdir = /home/samuel/envs/shanbay/src/ >> 20 home = ../ >> 21 pythonpath = ./ >> 22 module = django_wsgi. >> 23 >> 24 # set the project settings name >> 25 env = DJANGO_SETTINGS_MODULE=settings >> 26 >> 27 # load django >> 28 module = django.core.handlers.wsgi:WSGIHandler() >> 29 >> 30 >> 31 # uwsgi log >> 32 daemonize = ./log/uwsgi.log >> 33 logdate = true >> 34 logslow = true >> 35 logbig = true >> 36 log-5xx = true >> 37 >> 38 # use master process >> 39 master = true >> 40 # will set the uWSGI processes name to something meaningful >> automatically.. >> 41 auto-procname = true >> 42 >> 43 # use harakiri to kill requests cosing more than 20 seconds >> 44 harakiri = 20 >> 45 # you will be told why killed in detail. >> 46 harakiri-verbose = true >> 47 >> 48 >> 49 # memory leak , recycle worker if over 256M of address space growed. >> (not physicial memory) >> 50 # limit-as = 256M >> 51 # ecycle a workers when its address space usage is over the limit >> specified >> >> # reload-on-as = 128M. >> 53 >> 54 # Some of the supported languages (like python) has the concept of >> "multiple interpreters". They allows to isolate apps living in the same >> process. If you do not want this kind of f eature use this option.. >> 55 single-interpreter = true >> 56 >> 57 >> 58 # set pidfile. >> 59 pidfile = ./uwsgi.pid >> 60 touch-reload = ./uwsgi.touch >> > > and part of the log file: > >> Fri Apr 13 17:26:12 2012 - Set PythonHome to ../ >> 14 Fri Apr 13 17:26:12 2012 - Python main interpreter initialized at >> 0x1b2c140 >> 15 Fri Apr 13 17:26:12 2012 - your server socket listen backlog is >> limited to 3000 connections >> 16 Fri Apr 13 17:26:12 2012 - *** Operational MODE: preforking *** >> 17 Fri Apr 13 17:26:12 2012 - added .// to pythonpath. >> 18 Fri Apr 13 17:26:12 2012 - WSGI app 0 (mountpoint='') ready in 0 >> seconds on interpreter 0x1b2c140 pid: 9206 (default app) >> 19 Fri Apr 13 17:26:12 2012 - spawned uWSGI master process (pid: 9206) >> 20 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 1 (pid: 9207, cores: >> 1) >> 21 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 2 (pid: 9208, cores: >> 1) >> 22 Fri Apr 13 17:26:12 2012 - mapped socket 0 (:8080) to worker 1 >> 23 Fri Apr 13 17:26:12 2012 - mapped socket 0 (:8080) to worker 2 >> 24 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 3 (pid: 9209, cores: >> 1) >> 25 Fri Apr 13 17:26:12 2012 - mapped socket 0 (:8080) to worker 3 >> 26 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 4 (pid: 9210, cores: >> 1) >> 27 Fri Apr 13 17:26:12 2012 - mapped socket 0 (:8080) to worker 4 >> 28 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 5 (pid: 9211, cores: >> 1) >> 29 Fri Apr 13 17:26:12 2012 - mapped socket 0 (:8080) to worker 5 >> 30 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 6 (pid: 9212, cores: >> 1) >> 31 Fri Apr 13 17:26:12 2012 - mapped socket 1 (:8081) to worker 6 >> 32 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 7 (pid: 9213, cores: >> 1) >> 33 Fri Apr 13 17:26:12 2012 - mapped socket 1 (:8081) to worker 7 >> 34 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 8 (pid: 9214, cores: >> 1) >> 35 Fri Apr 13 17:26:12 2012 - mapped socket 1 (:8081) to worker 8 >> 36 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 9 (pid: 9215, cores: >> 1) >> 37 Fri Apr 13 17:26:12 2012 - spawned uWSGI worker 10 (pid: 9216, >> cores: 1) >> 38 Fri Apr 13 17:26:12 2012 - mapped socket 1 (:8081) to worker 9 >> 39 Fri Apr 13 17:26:12 2012 - mapped socket 1 (:8081) to worker 10 >> 40 Fri Apr 13 17:26:24 2012 - *** ./uwsgi.pid has been touched... grace >> them all !!! *** >> 41 Fri Apr 13 17:26:24 2012 - ...gracefully killing workers... >> 42 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 2 (pid: 9208)... >> 43 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 3 (pid: 9209)... >> 44 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 1 (pid: 9207)... >> 45 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 8 (pid: 9214)... >> 46 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 4 (pid: 9210)... >> 47 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 10 (pid: >> 9216)... >> 48 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 5 (pid: 9211)... >> 49 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 9 (pid: 9215)... >> 50 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 7 (pid: 9213)... >> 51 Fri Apr 13 17:26:24 2012 - Gracefully killing worker 6 (pid: 9212)... >> Fri Apr 13 17:26:24 2012 - Gracefully killing worker 6 (pid: 9212)... >> 52 Fri Apr 13 17:26:25 2012 - binary reloading uWSGI... >> 53 Fri Apr 13 17:26:25 2012 - chdir() to /home/samuel/envs/shanbay/src >> 54 Fri Apr 13 17:26:25 2012 - closing all non-uwsgi socket fds > 2 >> (max_fd = 1024)... >> 55 Fri Apr 13 17:26:25 2012 - found fd 4 mapped to socket 0 (:8080) >> 56 Fri Apr 13 17:26:25 2012 - found fd 5 mapped to socket 1 (:8081) >> 57 Fri Apr 13 17:26:25 2012 - running /usr/local/bin/uwsgi >> 58 [uWSGI] getting INI configuration from django.ini >> 59 Fri Apr 13 17:26:25 2012 - *** Starting uWSGI 1.1.2 (64bit) on [Fri >> Apr 13 17:26:25 2012] *** >> 60 Fri Apr 13 17:26:25 2012 - compiled with version: 4.6.1 on 13 April >> 2012 17:05:04 >> 61 Fri Apr 13 17:26:25 2012 - current working directory: >> /home/samuel/envs/shanbay/src >> 62 Fri Apr 13 17:26:25 2012 - detected binary path: /usr/local/bin/uwsgi >> 63 Fri Apr 13 17:26:25 2012 - your memory page size is 4096 bytes >> 64 Fri Apr 13 17:26:25 2012 - *** WARNING: you have enabled harakiri >> without post buffering. Slow upload could be rejected on post-unbuffered >> webservers ***. >> 65 Fri Apr 13 17:26:25 2012 - detected max file descriptor number: 1024 >> 66 Fri Apr 13 17:26:25 2012 - lock engine: pthread mutexes >> 67 Fri Apr 13 17:26:25 2012 - uwsgi socket 0 inherited INET address >> :8080 fd 4 >> 68 Fri Apr 13 17:26:25 2012 - uwsgi socket 1 inherited INET address >> :8081 fd 5 >> 69 Fri Apr 13 17:26:25 2012 - Python version: 2.7.2+ (default, Oct 4 >> 2011, 20:41:12) [GCC 4.6.1] >> 70 Fri Apr 13 17:26:25 2012 - Set PythonHome to ../ >> 71 Fri Apr 13 17:26:25 2012 - Python main interpreter initialized at >> 0x1597fc0 >> 72 Fri Apr 13 17:26:25 2012 - your server socket listen backlog is >> limited to 3000 connections >> 73 Fri Apr 13 17:26:25 2012 - *** Operational MODE: preforking *** >> 74 Fri Apr 13 17:26:25 2012 - added .// to pythonpath. >> 75 Fri Apr 13 17:26:25 2012 - WSGI app 0 (mountpoint='') ready in 0 >> seconds on interpreter 0x1597fc0 pid: 9206 (default app) >> 76 Fri Apr 13 17:26:25 2012 - gracefully (RE)spawned uWSGI master >> process (pid: 9206) >> 77 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 1 (pid: 9227, cores: >> 1) >> 78 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 2 (pid: 9228, cores: >> 1) >> 79 Fri Apr 13 17:26:25 2012 - mapped socket 0 (:8080) to worker 1 >> 80 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 81 Fri Apr 13 17:26:25 2012 - mapped socket 0 (:8080) to worker 2 >> 82 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 83 Fri Apr 13 17:26:25 2012 - mapped socket 0 (:8080) to worker 3 >> 84 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 85 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 3 (pid: 9229, cores: >> 1) >> 86 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 4 (pid: 9230, cores: >> 1) >> 87 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 5 (pid: 9231, cores: >> 1) >> 88 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 6 (pid: 9232, cores: >> 1) >> 89 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 7 (pid: 9233, cores: >> 1) >> 90 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 8 (pid: 9234, cores: >> 1) >> 91 Fri Apr 13 17:26:25 2012 - mapped socket 0 (:8080) to worker 4 >> 92 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 9 (pid: 9235, cores: >> 1) >> 93 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 94 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 95 Fri Apr 13 17:26:25 2012 - spawned uWSGI worker 10 (pid: 9236, >> cores: 1) >> 96 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 97 Fri Apr 13 17:26:25 2012 - mapped socket 0 (:8080) to worker 5 >> 98 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 99 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 100 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> 101 Fri Apr 13 17:26:25 2012 - dup2(): Resource temporarily unavailable >> [uwsgi.c line 2821] >> > > error log continues without any stop ... > > > > > > >> > > > On Fri, Apr 13, 2012 at 5:33 PM, Riccardo Magliocchetti < > [email protected]> wrote: > >> Hi Samuel, >> >> Il 13/04/2012 11:23, Samuel ha scritto: >> >> Thanks for your helps. >>> >>> my version is 0.9.9.2 >>> >> >> This is a quite old version, any chance you can upgrade to at least >> latest LTS (1.0.5) ? >> >> >> pidfile=uwsgi.pid >>> >>> touch-reload=uwsgi.pid >>>> >>>> then >>>> >>>> $ touch uwsgi.pid >>>> >>>> >>>> >>> so touch-reload and pidfile should be the same file. >>> >>> I thought touch-reload can be any file, and I just had a try to see if >>> set >>> touch-reload file as pid file, but no luck. I also tried on version >>> 1.1.12, >>> but the result is the same defunct status. >>> >> >> It can be anyfile, i think it is convenient to reuse the pidfile instead >> of adding another file. >> >> >> I meant defunct as the follow line if I executed ps -ef |grep -i uwsgi >>> >>> samuel 7751 7750 0 17:20 ? 00:00:00 [uwsgi]<defunct> >>> >>> please let me know if more info needed. >>> >>> >> Could you please post all your config file? Also if you are not already >> using logto please add >> >> logto=uwsgi.log >> >> and post the output >> >> >> thanks, >> riccardo >> >> ______________________________**_________________ >> uWSGI mailing list >> [email protected] >> http://lists.unbit.it/cgi-bin/**mailman/listinfo/uwsgi<http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi> >> > > > > -- > *吴焱红(Samuel)* > > 博客: blog.shanbay.com > 微博: 扇贝网 <http://www.weibo.com/shanbay> > 人人网: 一起背单词公共主页 <http://page.renren.com/699128841?ref=lnkprofile> > > > -- *吴焱红(Samuel)* 博客: blog.shanbay.com 微博: 扇贝网 <http://www.weibo.com/shanbay> 人人网: 一起背单词公共主页 <http://page.renren.com/699128841?ref=lnkprofile>
_______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
