Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
RPC Implementation Mechanism in Distributed System
Next article icon

RPC Implementation Mechanism in Distributed System

Last Updated : 16 Aug, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will go through the concept of the Remote Procedure Call (RPC) and its working mechanism.

RPC is an effective mechanism for building client-server systems that are distributed. RPC enhances the power and ease of programming of the client/server computing concept. It's a protocol that allows one software to seek a service from another program on another computer in a network without having to know about the network. The software that makes the request is called a client, and the program that provides the service is called a server.

The calling parameters are sent to the remote process during a Remote Procedure Call, and the caller waits for a response from the remote procedure. The flow of activities during an RPC call between two networking systems is depicted in the diagram below.

Remote Procedure Call Mechanism

Semantic Transparency:

  • Syntactic transparency: This implies that there should be a similarity between the remote process and a local procedure.
  • Semantic transparency: This implies that there should be similarity in the semantics i.e. meaning of a remote process and a local procedure.

Working of RPC:

There are 5 elements used in the working of RPC:

  • Client
  • Client Stub
  • RPC Runtime
  • Server Stub
  • Server

Implementation of RPC Mechanism

  • Client: The client process initiates RPC. The client makes a standard call, which triggers a correlated procedure in the client stub.
  • Client Stub: Stubs are used by RPC to achieve semantic transparency. The client calls the client stub. Client stub does the following tasks:
    • The first task performed by client stub is when it receives a request from a client, it packs(marshalls) the parameters and required specifications of remote/target procedure in a message.
    • The second task performed by the client stub is upon receiving the result values after execution, it unpacks (unmarshalled) those results and sends them to the Client.
  • RPC Runtime: The RPC runtime is in charge of message transmission between client and server via the network. Retransmission, acknowledgement, routing, and encryption are all tasks performed by it. On the client-side, it receives the result values in a message from the server-side, and then it further sends it to the client stub whereas, on the server-side, RPC Runtime got the same message from the server stub when then it forwards to the client machine. It also accepts and forwards client machine call request messages to the server stub.
  • Server Stub: Server stub does the following tasks:
    • The first task performed by server stub is that it unpacks(unmarshalled) the call request message which is received from the local RPC Runtime and makes a regular call to invoke the required procedure in the server.
    • The second task performed by server stub is that when it receives the server's procedure execution result, it packs it into a message and asks the local RPC Runtime to transmit it to the client stub where it is unpacked.
  • Server: After receiving a call request from the client machine, the server stub passes it to the server. The execution of the required procedure is made by the server and finally, it returns the result to the server stub so that it can be passed to the client machine using the local RPC Runtime.

RPC process:

  • The client, the client stub, and one instance of RPC Runtime are all running on the client machine.
  • A client initiates a client stub process by giving parameters as normal. The client stub acquires storage in the address space of the client.
  • At this point, the user can access RPC by using a normal Local Procedural Call. The RPC runtime is in charge of message transmission between client and server via the network. Retransmission, acknowledgment, routing, and encryption are all tasks performed by it.
  • On the server-side, values are returned to the server stub, after the completion of server operation, which then packs (which is also known as marshaling) the return values into a message. The transport layer receives a message from the server stub.
  • The resulting message is transmitted by the transport layer to the client transport layer, which then sends a message back to the client stub.
  • The client stub unpacks (which is also known as unmarshalling) the return arguments in the resulting packet, and the execution process returns to the caller at this point.

 

Client and Server StubClient and Server Stub

When the client process requests by calling a local procedure then the procedure will pass the arguments/parameters in request format so that they can be sent in a message to the remote server. The remote server then will execute the local procedure call ( based on the request arrived from the client machine) and after execution finally returns a response to the client in the form of a message. Till this time the client is blocked but as soon as the response comes from the server side it will be able to find the result from the message. In some cases, RPCs can be executed asynchronously also in which the client will not be blocked in waiting for the response. 

The parameters can be passed in two ways. The first is to pass by value, whereas the second is to pass by reference. The parameters receiving the address should be pointers when we provide it to a function. In Pass by reference, a function is called using pointers to pass the address of variables. Call by value refers to the method of sending variables' actual values.

The language designers are usually the ones who decide which parameter passing method to utilize. It is sometimes dependent on the data type that is being provided. Integers and other scalar types are always passed by value in C, whereas arrays are always passed by reference.


Next Article
RPC Implementation Mechanism in Distributed System

A

annieahujaweb2020
Improve
Article Tags :
  • Computer Networks
  • Geeks-Premier-League-2022

Similar Reads

    Limitations of Distributed Systems
    Distributed systems are essential for modern computing, providing scalability and resource sharing. However, they face limitations such as complexity in management, performance bottlenecks, consistency issues, and security vulnerabilities. Understanding these challenges is crucial for designing robu
    8 min read
    Distributed System - Parameter Passing Semantics in RPC
    A Distributed System is a Network of Machines that can exchange information with each other through Message-passing. It can be very useful as it helps in resource sharing. In this article, we will go through the various Parameter Passing Semantics in RPC in distributed Systems in detail. Parameter P
    4 min read
    Handling Duplicate Messages in Distributed Systems
    Duplicate messages in distributed systems can lead to inconsistencies, inefficiencies, and incorrect data processing. To ensure reliability and correctness, effectively handling duplicates is crucial. This article explores the causes, challenges, and techniques for managing duplicate messages in dis
    8 min read
    Distributed System Patterns
    Distributed system patterns are abstract ways of structuring a system that helps developers solve recurring design problems. They provide proven solutions that can be reused across different applications and help developers make informed decisions and avoid common pitfalls. In this article, we will
    10 min read
    Performance Evaluation for Distributed Systems
    Performance evaluation in distributed systems is crucial for ensuring that applications and services meet their performance goals and provide a satisfactory user experience. Distributed systems, which rely on multiple interconnected nodes to function, face unique performance challenges that require
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences