UWSGI_DEPLOY.md 1.6 KB
Newer Older
M
fix doc  
MRXLT 已提交
1
# Deploy HTTP service with uWSGI
M
MRXLT 已提交
2

M
MRXLT 已提交
3 4
([简体中文](./UWSGI_DEPLOY_CN.md)|English)

M
fix doc  
MRXLT 已提交
5
In fit_a_line example, after starting the HTTP prediction service, you will see the following information:
M
MRXLT 已提交
6 7 8 9 10 11 12 13 14 15 16 17

```shell
web service address:
http://10.127.3.150:9393/uci/prediction
 * Serving Flask app "serve" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:9393/ (Press CTRL+C to quit)
```

M
fix doc  
MRXLT 已提交
18 19
Here you will be prompted that the HTTP service started is in development mode and cannot be used for production deployment. 
The prediction service started by Flask is not stable enough to withstand the concurrency of a large number of requests. In the actual deployment process, WSGI (Web Server Gateway Interface) is used.
M
MRXLT 已提交
20

M
fix doc  
MRXLT 已提交
21
Next, we will show how to use the [uWSGI] (https://github.com/unbit/uwsgi) module to deploy HTTP prediction services for production environments.
M
MRXLT 已提交
22 23 24 25 26 27


```python
#uwsgi_service.py
from paddle_serving_server.web_service import WebService

M
fix doc  
MRXLT 已提交
28
#Define prediction service
M
MRXLT 已提交
29 30 31
uci_service = WebService(name = "uci")
uci_service.load_model_config("./uci_housing_model")
uci_service.prepare_server(workdir="./workdir", port=int(9500), device="cpu")
M
MRXLT 已提交
32
uci_service.run_rpc_service()
M
fix doc  
MRXLT 已提交
33 34
#Get flask application
app_instance = uci_service.get_app_instance()
M
MRXLT 已提交
35 36
```

M
fix doc  
MRXLT 已提交
37
Start service with uWSGI
M
MRXLT 已提交
38 39

```bash
M
fix doc  
MRXLT 已提交
40
uwsgi --http :9393 --module uwsgi_service:app_instance
M
MRXLT 已提交
41 42
```

M
fix doc  
MRXLT 已提交
43
Use the --processes parameter to specify the number of service processes. 
M
MRXLT 已提交
44

M
fix doc  
MRXLT 已提交
45
For more information about uWSGI, please refer to [uWSGI documentation](https://uwsgi-docs.readthedocs.io/en/latest/)