日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

Django + Nginx + Uwsgi + Celery + Rabbitmq 做一个高速响的应网站架构

發(fā)布時間:2025/4/14 85 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Django + Nginx + Uwsgi + Celery + Rabbitmq 做一个高速响的应网站架构 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Django :渲染頁面,站點訪問控制,管理網(wǎng)站,網(wǎng)站框架

Nginx:ip訪問管理,數(shù)據(jù)傳輸控制

Uwsgi:處理鏈接Diango和Nginx的傳輸協(xié)議,也可以看作是處理客戶端數(shù)據(jù)和Django之間的通信協(xié)議,Django原生支持

Celery:任務(wù)調(diào)度處理,用于應(yīng)用異步任務(wù)處理,任務(wù)持久化等,消息中間件,django-celery原生支持

Rabbitmq:消息隊列用于進程間通信,數(shù)據(jù)持久化等, 配合消息中間件使用,支持Celery

?

配置:Django+Nginx+Uwsgi? ? ? ?https://uwsgi.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

uwsgi.ini配置

[uwsgi]

socket=:8001
chdir=path/to/uwsgi.ini
module=djangoProjectName.wsgi:application
master=True
pidfile=/tmp/project-master.pid
vacuum=True
max-requests=5000
daemonize=/var/log/uwsgi/oj.log

啟動命令:uwsgi --ini uwsgi.ini --enable-threads

Nginx配置

upstream django {
  # server unix:///path/to/your/mysite/mysite.sock; # for a file socket  unix .sock通信方式
  server 127.0.0.1:8001; # for a web port socket (we'll use this first)  web port socket通信方式,對應(yīng)uwsgi.ini的socket設(shè)置
}

# configuration of the server
server {
  # the port your site will be served on
  listen 8000;
  # the domain name it will serve for
  server_name .example.com; # substitute your machine's IP address or FQDN
  charset utf-8;

  # max upload size
  client_max_body_size 75M; # adjust to taste

  location /static{

    alias path/to/website/static

  }

  # Finally, send all non-media requests to the Django server.
  location / {
    uwsgi_pass django;
    path/to/uwsgi_params; # the uwsgi_params file you installed
  }
}

?

rabbitmq簡單配置:http://docs.celeryproject.org/en/latest/getting-started/brokers/rabbitmq.html#id3

rabbitmq配合celery簡單使用:http://docs.celeryproject.org/en/latest/getting-started/brokers/rabbitmq.html#id3

celery配合Django簡單使用:https://www.cnblogs.com/alex3714/p/6351797.html

轉(zhuǎn)載于:https://www.cnblogs.com/akfheaven/p/9228741.html

總結(jié)

以上是生活随笔為你收集整理的Django + Nginx + Uwsgi + Celery + Rabbitmq 做一个高速响的应网站架构的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。