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

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

```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 已提交
16 17
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 已提交
18

M
fix doc  
MRXLT 已提交
19
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 已提交
20 21 22 23 24 25


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

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

M
fix doc  
MRXLT 已提交
35
Start service with uWSGI
M
MRXLT 已提交
36 37

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

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

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