DEV Community

Explain RPC like I'm Five

Martin Becker on May 17, 2018

I'm having a little trouble understanding RPC, especially compared to say Rest API's or using protobufs to send and receive data, so please explain RPC like I'm Five?

Collapse
 
spidergears profile image
Deepak Singh

RPC == Remote Procedure Call

Procedure:

A function or method that does something meaningful and worth the efforts. Has knowledge about your business logic.

Procedure Call:

The action of invoking a function/method to execute the logic contained within

Remote:

Not in close proximity.

Remote Procedure Call:

Invoking a function/method that is not in proximity to the caller.

Proximity in Context of code:

--------------ENV 1----------------
Method A
Method B
--------------ENV 1----------------

--------------ENV 2----------------
Method C
Method D
--------------ENV 2----------------

Between ENV 1 and ENV 2,

  • methods A & B are in proximity i.e. within the same execution environment
  • methods C & D are in proximity i.e. within the same execution environment
  • methods C & D are remote to methods A & B, and vice-versa

The execution environments are capable of communication among themselves via a given medium, which can be

  • Inter-process communication
  • Over the wire (HTTP)
  • a few more

Any invocation methods A & B within ENV 2, and any invocation methods C & D within ENV 1, is to be referred to as RPC.

Collapse
 
nikolicstjepan profile image
Nikolić Stjepan

Thanks Deepak for this explanation, this was what I needed! :)

Collapse
 
logifire profile image
Logifire

By this, can you say, if you have implemented a REST service and calling this over HTTP, you are implicit doing RPC?

Collapse
 
spidergears profile image
Deepak Singh

yes, that would be correct.
Your application environment is remote to your server environment. HTTP is your medium of communication, logic contained within your REST APIs are remote procedures.

Another similar example would be web-sockets, where both your client and server can invoke remote calls on each other by the exchange of events.