Sunday, August 28, 2022
gRPC vs REST vs GraphQL
𝗚𝗿𝗮𝗽𝗵𝗹𝗤𝗟 is a data query language that uniquely allows clients to request any specific data that they need. As opposed to REST’s HTTP methods, GraphQL uses queries, mutations, and subscriptions for sourcing and manipulating data. Queries request data from the server while mutations send data to and modify data gated by the server. Subscriptions get live updates when data changes, usually through Websockets.
𝗥𝗘𝗦𝗧 The most popular and most used API format on the list is REST, which stands for representational state transfer. REST APIs use HTTP methods like GET, POST, PUT, and DELETE to access and manipulate data within uniform resource identifiers (URIs).
𝗴𝗥𝗣𝗖 is a high-performance, open source remote procedural call (RPC) framework created by Google. In gRPC, protocol buffers make API requests to the server. These API requests and responses are protocol buffer messages, and each one must have its own type defined using the protocol buffers language.
So, 𝘄𝗵𝗶𝗰𝗵 𝗼𝗻𝗲 𝗶𝘀 𝘁𝗵𝗲 𝗯𝗲𝘀𝘁?
- The winner is, of course, “𝗶𝘁 𝗱𝗲𝗽𝗲𝗻𝗱𝘀.” Each technology has strong benefits, but those come with trade-offs. Your needs may best be served by a combination of technologies.
- 𝗥𝗘𝗦𝗧, 𝗼𝗿 𝗮𝘁 𝗹𝗲𝗮𝘀𝘁 𝗝𝗦𝗢𝗡 𝗼𝘃𝗲𝗿 𝗛𝗧𝗧𝗣, is the most ubiquitous standard for web-based APIs. This means it’s easy to get started, you can use a wide variety of languages, and it works natively with web browsers.
- In their own way, 𝗚𝗿𝗮𝗽𝗵𝗤𝗟 𝗮𝗻𝗱 𝗴𝗥𝗣𝗖 address some of the limitations of REST.
- 𝗚𝗿𝗮𝗽𝗵𝗤𝗟 allows a client to specify just the information they need, which can greatly reduce duplicate or unnecessary data being transmitted. But, it requires additional setup and training.
- 𝗴𝗥𝗣𝗖 is built for fast transport, leveraging HTTP/2. This requires a well known contract, typically using Protocol Buffers, that is shared by the client and server.
Subscribe to:
Posts (Atom)