Making Django go green

前端 未结 2 1809
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 12:45

I have a Django management command that makes thousands of TCP/UDP requests. I\'ve used Gevent to speed this up as I\'ve restructured my code to work as coroutines. The socket c

2条回答
  •  -上瘾入骨i
    2021-02-04 12:55

    gevent will not green third-party libraries as long there are using either C extensions or using other third-party libraries which are using C extensions. If standard libraries are used gevent is able to monkey patch them.

    Some database drivers rely of course on the database implementation itself. Just because you use a greened library does not mean you database will behave "green". This also need to be invoked on the database level itself. Prosgresql for example does support async command processing since version 2.2.

    Also you might want to check Projects using gevent.

    Gunicorn will make life easier for you, at least when you start to deploy your application. Also during development I would recommend gunicorn (with gevent) over the normal django runserver command, simply because it can handle simultaneous requests way faster.

提交回复
热议问题