gRPC vs GraphQL vs REST? What's the best API Technology for Golang?

preview_player
Показать описание
gRPC? GraphQL? REST? What is the best API Technology for Go/Golang? What tools are available for implementing them?

In this video I cover the key differences between these three popular API technologies, introducing you to them, sharing with you the pros and cons and giving you my opinion regarding what's the best API Technology to use depending on the use case, also with some example of tools to use in Go/Golang.

== What is REST?

REST is an acronym for REpresentational State Transfer coined by Roy Fielding and introduced in his doctoral dissertation, it is an architectural style that defines guidelines when building web services, it’s not a standard but it does use standards like HTTP (and its verbs to represent actions) and payload/message formats (like JSON or XML), to mention a few.

==== Pros
■ Easy to implement and use
■ Mature, literally all programming languages allow you to implement and build REST APIs

==== Cons
■ Overfetching, indicates responses include data that is not needed by the customer
■ Underfetching, indicates the need to call multiple resources to get all the needed data

==== Tools

== What is GraphQL?

GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.

==== Pros
■ No overfetching, every field is explicitly indicated.
■ Strongly Typed

==== Cons
■ Complex Backend Querying, because all the querying logic is shifting to the Backend
■ Caching is more difficult

== What is gRPC?

gRPC is an efficient open source remote procedure call (RPC) that generates cross-platform client and server bindings defined in Protocol Buffers.

==== Pros
■ Includes tools for code generation
■ Highly performant

==== Cons
■ Harder to implement
■ There's no (default) browser support

== When to use REST, GraphQL or gRPC?
My recommendations are:
■ Use REST when building an API that has a though deadline and where the domain can be easily mapped to resources
■ Use GraphQL when building an API that is heavy on querying resources or when payload performance is needed
■ Use gRPC when building Backend APIs with high throughput and concrete requirements.

== Relevant links

== All Go/Golang Playlists

== Socials

00:00 - Start
00:12 - What is Data Exchange?
00:35 - REST: Data Exchange, Pros and Cons
04:32 - GraphSQL: Data Exchange, Pros and Cons
07:12 - gRPC: Data Exchange, Pros and Cons
10:25 - What is the best API Technology?

=== Who am I?

Hello👋🏼! I'm Mario, a Hands-on Software Architect and Lead Backend Engineer with more than 16 years of professional experience building all kinds of software including on-premise Industrial Automation Systems, Linux Accessibility Desktop and Browser Components as well as Distributed Advertising Microservices.

Every week I will share with you different topics I've learned while working for small startups and large companies including the processes I've followed over the years for successfully delivering complex enterprise systems from start to end.

Subscribe if you like Software Development, Software Architecture and System Design!

Keep it up. Don't give up!

#golang #softwarearchitecture #systemdesign

=== Our Vlog Channel

=== Affiliate links

DISCLAIMER: Some of the links shared above are affiliate links. As a member of these affiliate programs, I earn a small commission from your purchases at no additional cost to you. Thank you in advance for your support!
Рекомендации по теме
Комментарии
Автор

Completely agree with these pros & cons. People shouldn't underestimate just *how* much more expensive it can be to implement GraphQL, by the way, if you are doing anything at all complex and custom in your backend (i.e. not just reading from a database). It makes the problem of overfetching in REST very small by comparison. I would say, as a general rule, try to make REST work first.

benisrood
Автор

This is great information, beyond the scope of Golang actually. Thanks!

yo_mono
Автор

Most underrated Go channel (see what I did there?) out there, amazing work Mario. Is there a way we can support your work?

fruedal
Автор

Me gusta como explicas, muy claro, seguiré viendo tus videos, gracias!!!

kalmecakrc
Автор

Thanks for creating this video, very clear explanation and easy to understand. Helps me as a product person to know better

littlevintagelady
Автор

Regarding the under-fetching con in REST, you can just apply filters on a list endpoint and get only the permissions, w/o other users' details. sure, it's still a loop in your logic, but another endpoint like /users/{userId}/permissions to hit in each loop iteration is not really necessary.

mateicheles
Автор

estoy confundido necesito consultar una db dgrpah con go, y tanta documentacion me dejo mas confundido donde puedo ir puntualmente para hacer esa gestion?

ruizdani
Автор

thank you for sharing this information

koro
Автор

Thank you Mario. It's amazing video.

Peter-xnbk
Автор

Worked at a company where we moved all our internal endpoints to gRPC, because the staff engineer that proposed it wants our backend communication protocol because it is language agnostic while our whole backend stack is written Java or in the process of migrating to Java.

The engineer that proposed it got a promotion while the migration to gRPC provided no business and engineering value other than costing the company millions in lost engineering hours.

yiyao
Автор

graphql with golang is extremely hard and complicate and cannot understand the world of golang is weak on this part, then most of plugins use schema first not code first like "graphql-go", and for my personal experience until now upload file with graphql not working in golang

kamalkamals
Автор

Hey Mario you explain so nicely. Alright, I have a question. I want to build an app that will be having user profiles, calling features, geo-fencing, geo-tagging, voice & photo sharing(ephemeral) and a bit of social features. Could you tell me what backend programmer should I hire? Because right now, I do have a Golang programmer who works with GRPC as well as a NodeJS developer and he works with Appsync(GraphQL). Also, I do have an iOS developer who can connect the final endpoints to the Xcode using Swift once the backend is ready. I really would like to take the serverless approach this is why AWS Lambda fits well to me but a GRPC needs an active server hence it can not be used with Lambda. Could you tell me which programmer would be best at my case for building the app logic, business logic and the complete backend.
Please do reply.
Thanks.

xcBenevolent
Автор

What about gRPC-Web for Frontend to Backend gRPC use tho?

Iull
Автор

Thanks for making this, good information and easy to digest

liftingisfun
Автор

Only one thing to change about your else beautiful explanation:
GraphQL is very inefficient performance wise. By many points of view. It also has very annoying N+1 problems that are not that easy to solve sometimes

xcffee_
Автор

I'm sorry, but your pronunciation is confusing.

abgthscode