Why RPC Beats HTTP for Enterprise Services: Architecture, Sync/Async, and Top Frameworks
This article explains the technical differences between RPC and HTTP services, covering the OSI model, RPC architecture, synchronous versus asynchronous calls, and compares popular frameworks like gRPC, Thrift, and Dubbo to help developers choose the right approach for large‑scale systems.
Introduction
RPC is built on the TCP/IP protocol while HTTP services rely on the HTTP protocol, which itself runs over TCP. Because RPC communicates directly over TCP, it generally offers higher efficiency than HTTP.
OSI Seven‑Layer Model
Understanding the OSI model (often simplified to five layers in practice) helps explain why RPC can be more efficient. The key layers are:
Application layer – defines communication interfaces.
Presentation layer – handles data formatting and encoding.
Session layer – manages sessions.
Transport layer – provides end‑to‑end data transfer (TCP).
Network layer – routes data between devices.
Data link layer – packages network‑layer data into frames.
Physical layer – transmits binary signals.
In most real‑world applications the presentation and session layers are merged with the application layer, leaving the focus on the application and transport layers (HTTP at the application layer, TCP at the transport layer).
RPC Services
Architecture
An RPC system consists of four core components: Client, Server, Client Stub, and Server Stub.
Client – the caller of the service.
Server – the provider of the service.
Client Stub – stores server address information, packages request parameters into network messages, and sends them to the server.
Server Stub – receives messages, unpacks them, and invokes the local method.
RPC is commonly used in large enterprises where many subsystems and high efficiency are required. Projects typically use Maven to manage dependencies, share interface definitions as Java interfaces, and package them into JARs for both client and server, reducing client JAR size and decoupling the two sides.
Synchronous vs Asynchronous Calls
Synchronous calls block the client until the result is returned. Asynchronous calls return immediately; the client can receive the result later via callbacks or futures, similar to Java's Callable and Future versus Runnable.
Popular RPC Frameworks
Three widely used open‑source RPC frameworks are highlighted:
gRPC – developed by Google, based on HTTP/2, supports many languages, and uses Netty under the hood.
Thrift – originated at Facebook, provides cross‑language service development with an IDL compiler that generates code.
Dubbo – Alibaba’s mature framework, featuring pluggable protocols and serialization, integrates tightly with Spring, and supports packaging services as standalone processes.
HTTP Services
HTTP (often RESTful) is simple and convenient for small‑scale or low‑traffic scenarios. It uses standard HTTP methods and returns JSON or XML payloads. However, for large enterprises with many internal systems, RPC offers advantages such as persistent connections, reduced handshake overhead, built‑in service registries, and unified monitoring.
Conclusion
RPC and HTTP serve different needs: RPC excels in high‑performance, large‑scale enterprise environments, while HTTP is faster to develop for smaller projects. Choosing the right approach requires a thorough evaluation of project requirements rather than following trends.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
