RPC vs REST
π§΅
π§΅
While building web APIs, different developers opt for different technologies.
REST and RPC are two of them. In this thread, we will take a deep look into them.
REST and RPC are two of them. In this thread, we will take a deep look into them.
π RPC
RPC stands for Remote Procedure Call.
In RPC, the client calls a function whose implementation is defined in the remote server. Hence it is called a Remote Procedure Call.
RPC stands for Remote Procedure Call.
In RPC, the client calls a function whose implementation is defined in the remote server. Hence it is called a Remote Procedure Call.
RPC is similar to calling a normal function but over the network and between different computers.
The below points describe the typical workflow of RPC. ππ»
The below points describe the typical workflow of RPC. ππ»
β’Β Client calls a function defined on the server-side.
β’ Function first encodes the argument that needs to pass to the server.
β’ Server decodes the argument and calls the function.
β’ Function returns the value.
β’ Server sends it back to the client.
β’ Function first encodes the argument that needs to pass to the server.
β’ Server decodes the argument and calls the function.
β’ Function returns the value.
β’ Server sends it back to the client.
RPC APIs are actions oriented.
Each endpoint represents an action. For example,
`GET /getUsers/2`
Here `getUser` is an action that might be typically defined inside a `getUser(id)` function on the server-side.
Each endpoint represents an action. For example,
`GET /getUsers/2`
Here `getUser` is an action that might be typically defined inside a `getUser(id)` function on the server-side.
π REST
REST stands for REpresentational State Transfer.
An API needs to follow six constraints to be a REST API. They are as follows. ππ»
REST stands for REpresentational State Transfer.
An API needs to follow six constraints to be a REST API. They are as follows. ππ»
1. Client-server Separation
2. Stateless
3. Cacheable
4. Layered System
5. Uniform Interface
6. Code on Demand (optional)
Read more about them:
2. Stateless
3. Cacheable
4. Layered System
5. Uniform Interface
6. Code on Demand (optional)
Read more about them:
REST APIs are resource-oriented.
Each endpoint should represent the resource's name (noun) not actions (verb). For example,
`GET /users/2`
Each endpoint should represent the resource's name (noun) not actions (verb). For example,
`GET /users/2`
A typical REST API utilizes HTTP verbs t perform actions. They are GET, POST, PUT, etc.
The major difference between RPC and REST is RPC is action-oriented, whereas REST is resource-oriented.
Typically RPC operates on UDP, and TCP while REST operates on HTTP.
Both REST and RPC are quite popular and it's hard to declare one as the best over the other.
Both REST and RPC are quite popular and it's hard to declare one as the best over the other.
With that said, this is pretty much it for this thread.
Follow @Rapid_API for more exclusive content. ππ
Follow @Rapid_API for more exclusive content. ππ
Loading suggestions...