Sobes.tech
Senior

Is it possible to implement RPC via REST and vice versa? What is the fundamental difference?

sobes.tech AI

Answer from AI

RPC (Remote Procedure Call) and REST are different approaches to interaction between services.

Can RPC be implemented over REST? Yes, it can. REST uses HTTP and can transmit method calls via URL and request body, mimicking remote procedure calls. For example, a POST request with JSON containing the method name and parameters.

Can REST be implemented over RPC? Technically, yes, but it wouldn't be quite REST, as REST is resource-oriented and uses standard HTTP methods (GET, POST, PUT, DELETE), whereas RPC focuses on calling procedures.

Fundamental difference:

  • REST is an architectural style focused on resources and their states, using standard HTTP methods.
  • RPC is a call to remote functions or procedures, focusing on actions.

In Go, gRPC (RPC over HTTP/2) is often used for high-performance services, while REST is used for simpler and more universal APIs.

Is it possible to implement RPC via REST and vice… - sobes.tech