Skip to Content
Python Microservices Development
book

Python Microservices Development

by Tarek Ziadé
July 2017
Beginner to intermediate
340 pages
7h 43m
English
Packt Publishing
Content preview from Python Microservices Development

GZIP compression

The first simple thing you can do to reduce the bandwidth is to use GZIP compression, so everything that is sent over the wire gets smaller. Web servers such as Apache or nginx provide native support to compress responses on the fly, and it's better to avoid implementing your ad hoc compression at the Python level.

For example, this nginx configuration will enable GZIP compression for any response produced by the Flask app on port 5000, with an application/json content type:

    http {         gzip  on;         gzip_types application/json;         gzip_proxied      any;         gzip_vary on;          server {             listen       80;             server_name  localhost;                         location / {                  proxy_pass http://localhost:5000;             }         } 

From the client-side, making an HTTP request to the nginx server ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Microservices Development - Second Edition

Python Microservices Development - Second Edition

Simon Fraser, Tarek Ziadé
Python Web Development with Sanic

Python Web Development with Sanic

Stephen Sadowski, Adam Hopkins

Publisher Resources

ISBN: 9781785881114Supplemental Content