GithubHelp home page GithubHelp logo

uwsgi-research's Introduction

uwsgi部署

从事Python web开发的朋友都知道uWSGI,想必也用uWSGI部署过web项目。可能都注意到uWSGI提供的若干部署选项,其中有三个选项 --http、--socket和--http-socket。如果没有仔细阅读其文档还真容易把它们给搞混。

--http

官方文档中有这么一句话来介绍在何种情况下使用此选项

If you plan to expose your app to the world with uWSGI only, use the http option instead, 
as the router/proxy/load-balancer will then be your shield.

如果你打算只用uWSGI来接收客户端发送过来的请求的话,就可以使用这个选项。 一般情况下我们会在web容器前在加一个HTTP服务器或者反向代理服务器, 但是如果你打算直接裸跑uWSGI的话,那就可以使用--http这个选项来部署你的web应用。

如果你打算把uWSGI放在完整的HTTP服务器(比如Nginx)之后,你有两种选择,--socket和--http-socket。 这取决于你的HTTP服务器使用何种协议与uWSGI沟通。下文中以Nginx为例

--socket

如果你的Nginx使用uwsgi协议与uWSGI沟通的话,即如下配置

location / {
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:3031;
}

上面的指令所表示的就是如果Nginx接收到请求后,会把请求以uwsgi协议发送给uWSGI。

--http-socket

但是如果你的Nginx使用HTTP协议与uWSGI沟通的话,即如下配置

location / {
    include /etc/nginx/proxy_params;
    proxy_pass http://127.0.0.1:3031;
}

上面的指令所表示的就是如果Nginx接收到请求后,会把请求以HTTP协议发送给uWSGI。

为什么会有uwsgi协议,因为对uWSGI来说,这个协议处理起来比HTTP协议快。

展示了uwsgi的三种部署方式

uwsgi-http

docker build . -t uwsgi-http:release
docker run -p 8001:8001 -d uwsgi-http:release

uWSGI-http-socket

docker build . -t uwsgi-http-socket:release
docker run -p 8002:8001 -d uwsgi-http-socket:release

uWSGI-socket

docker build . -t uwsgi-socket:release
docker run -p 8003:8001 -d uwsgi-socket:release

uWSGI-Flask

docker build . -t uwsgi-flask:release
docker run -p 8004:8001 -d uwsgi-flask:release

uWSGI-Django

docker build . -t uwsgi-django:release
docker run -p 8005:8001 -d uwsgi-django:release

uwsgi-research's People

Contributors

huangjiansheng01 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.