TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  • Distributed Operating System: Remote Procedure Call (RPC)

    Introduction

    Remote Procedure Call (RPC) ek communication technique hai jo distributed systems me use hoti hai. Ye allow karta hai ki ek program remotely kisi doosre system ke procedure ko call kar sake bina uski implementation ki details jaane. RPC client-server model par kaam karta hai jisme ek process (client) remotely doosri process (server) ke function ko invoke karta hai jaise wo local function ho.

    RPC ka real-world example hai Google Drive Sync, jisme ek client request karta hai remote Google server se file sync karne ke liye bina uski internal working ko samjhe.


    How RPC Works?

    Jab ek client RPC ka use karta hai to wo local function call karne jaisa lagta hai, lekin uska execution remotely hota hai. Is process me stubs aur marshalling ka use hota hai taaki remote function calls efficiently process ho sakein.

    📌 Diagram:

    Client Process     Server Process
    +------+                 +------+
    |      |Request Procedure|      |
    |Client| --------------> |Server|
    |      |                 |      |
    |      | Return Result   |      |
    |      | <-------------- |      |
    +------+                 +------+
     

    Steps of RPC Execution:

    1️⃣ Client function ek remote procedure ko call karta hai.
    2️⃣ Client stub procedure ko serialize karta hai (marshalling) aur network ke through bhejta hai.
    3️⃣ Server stub request receive karta hai, unmarshalling karta hai aur procedure execute karta hai.
    4️⃣ Server function ka result wapas server stub ko bhejta hai.
    5️⃣ Server stub result ko marshall karke network ke through client stub ko send karta hai.
    6️⃣ Client stub unmarshalling karke client process ko result return karta hai.


    Components of RPC

    RPC system ke different components hote hain jo communication establish karte hain:

    1. Client Process

    • Ye remote function ko call karta hai.

    • Client stub function ko initiate karta hai.

    2. Client Stub

    • Function call ko network me send karne ke liye convert karta hai (marshalling).

    • Server se response receive karke result client ko return karta hai.

    3. RPC Runtime

    • Ye communication module hai jo client aur server ke beech data transfer karta hai.

    4. Server Stub

    • Request ko receive karke usko unmarshall karta hai.

    • Server procedure ko execute karata hai aur result wapas send karta hai.

    5. Server Process

    • Remote function ka actual execution yahan hota hai.

    📌 Diagram Representing Components of RPC:

    +-------+    +------+    +------+    +-------+
    |Client |--->|Client|--->|Server|--->|Server |
    |Process|    | Stub |    | Stub |    |Process|
    +-------+    +------+    +------+    +-------+
     

    Types of RPC

    RPC ko execution ke tareeke ke basis par different types me divide kiya jata hai:

    1. Synchronous RPC

    • Client ek request bhejta hai aur response aane tak wait karta hai.

    • Example: Banking Transactions jisme ek transaction complete hone tak agli request nahi bheji jati.

    2. Asynchronous RPC

    • Client request bhejta hai aur bina wait kiye next task execute karta hai.

    • Example: Email Services, jisme mail bhejne ke baad user doosra kaam kar sakta hai.


    Advantages of RPC

    ✔ Transparency: Remote function call bilkul local function jaisa lagta hai.
    ✔ Modularity: Client aur server alag-alag design kiye ja sakte hain.
    ✔ Efficiency: Network latency ko kam karne ke liye optimized stubs ka use hota hai.
    ✔ Language Independent: C, Java, Python jaise alag-alag languages RPC ko support karti hain.


    Challenges in RPC

    🔴 Network Latency: Slow network hone par remote function calls slow ho sakti hain.
    🔴 Failure Handling: Agar server crash ho jaye to client ko response nahi milega.
    🔴 Security Issues: Data transmission me unauthorized access ka risk hota hai, isliye encryption ka use zaroori hai.
    🔴 Compatibility: Different systems aur architectures ke beech RPC communication kaafi complex ho sakta hai.


    Examples of RPC in Real World

    SystemDescription
    Google Drive SyncRemote function calls ka use karke file synchronization karta hai.
    Remote Desktop Protocol (RDP)Ek system remotely doosre system ko access kar sakta hai.
    Network File System (NFS)Remote file sharing ke liye RPC ka use hota hai.
    Database Systems (MySQL, PostgreSQL)Remote queries execute karne ke liye RPC architecture ka use hota hai.

    Security in RPC

    Remote communication me security critical hoti hai. Isliye RPC Secure (RPCSEC) jaise protocols ka use hota hai.

    🔹 Authentication: User verification ke liye login system ka use hota hai.
    🔹 Encryption: Data transfer me security ensure karne ke liye SSL/TLS encryption ka use hota hai.
    🔹 Access Control: Client ko sirf authorized functions access karne ki permission hoti hai.


    Conclusion

    RPC ek powerful communication mechanism hai jo distributed systems me client aur server ke beech seamless interaction provide karta hai. Ye system ko efficient, modular aur scalable banata hai.

    Scroll to Top