We will quickly recall what we covered in this section about performing synchronous calls:
- Requests can be used as the HTTP client to call other services. It offers all the features necessary to deal with timeouts, errors, and has its pool of connectors.
- Going multithread can improve your microservice's performance when it's calling other services, since Flask is a synchronous framework, but it's dangerous. Solutions such as Gevent can be investigated.
- Implementing HTTP cache headers is a great way to speed up repeated requests for data.
- GZIP compression is an efficient way to lessen the size of requests and responses and is easy to set up.
- Binary protocols are an attractive alternative to plain JSON, but might not be that useful.
The next section will focus on asynchronous calls; everything your microservice can do that goes beyond the request-response pattern.