in

Practical API Design Using gRPC at Netflix


A two-part series of articles about API design at Netflix was recently published in the company’s technology blog. It describes how they solved the problem of ignoring irrelevant message fields in their backend API requests and responses by using the special Protocol Buffers (Protobuf) message FieldMask.

Alex Borysov and Ricky Gardiner, senior software engineers at Netflix, note that API clients often do not use all the fields present in the responses to their requests. This transmission and computation of irrelevant information for one specific request can waste bandwidth and computational resources, increase the error rate, and increase the overall latency.

The authors argue that such waste can be avoided when API clients specify which fields are relevant to them with every request. They point out that this feature is present out of the box with API standards such as GraphQL and JSON:API and question whether Netflix’s wide usage of gRPC in the backend could benefit from an identical mechanism.

They found that a particular message called FieldMask is defined in Protobuf, the underlying message encoding of gRPC. When included in API requests, it allows clients to list which fields are relevant and can be applied to both read and modify operations.


Source: https://netflixtechblog.com/practical-api-design-at-netflix-part-1-using-protobuf-fieldmask-35cfdc606518

The authors also describe the pattern chosen for managing the evolution of each API’s data model while maintaining some degree of backward compatibility. Old fields are deprecated in favour of new ones, and they advocate for requiring a valid field mask or a version number with every update operation.

The need to optimise the overall footprint of API traffic is also felt in different domains. Others have also concluded that it is beneficial to allow clients to control which data is transmitted. As the consultant Adam DuVander points out in his earlier article about API request flexibilisation, “a bit too much or too little data may seem trivial, but in aggregate they can have a huge impact”. Adam shows how different API implementations addressed this issue.

Detailed code and Protobuf message examples are provided in the article to illustrate how FieldMask messages are used at Netflix.





Source: https://www.infoq.com/news/2021/09/practical-api-design-netflix/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

GIPHY App Key not set. Please check settings

Middle Class Lyrics — Sivakumarin Sabadham

A catalogue of React components focused on ease-of-use