When to Choose RPC Over REST
You'll learn: When RPC's action-oriented model and performance characteristics make it a better fit than REST.
Understanding the Choice
Choosing between RPC and REST isn't about one being "better"—it's about matching your architecture to your needs. REST excels when you're modeling resources with standard CRUD operations, but RPC shines when you're modeling actions or need maximum performance.
When RPC Makes Sense
Action-Oriented Operations
If your API is naturally about performing operations rather than manipulating resources, RPC feels more natural. Think: CalculateTax(), ProcessPayment(), or ConvertVideo(). Forcing these into REST's resource model can feel awkward—you'd end up creating artificial resources just to fit the pattern.
Performance-Critical Systems
When you've learned about gRPC's binary protocols and HTTP/2 multiplexing (from lesson 803), you saw RPC's performance advantages. For microservices with high-frequency internal communication, low latency matters. RPC's compact binary encoding and connection reuse can significantly reduce overhead compared to REST's text-based JSON over HTTP/1.1.
Strongly-Typed Internal APIs
The Interface Definition Languages (IDLs) you learned about provide compile-time type safety and automatic code generation. For internal service-to-service communication where both sides are under your control, this catches errors early and reduces integration bugs.
When REST Still Wins
REST remains better for public APIs where simplicity, cacheability, and broad compatibility matter. HTTP caching, standard tooling, and human-readable formats make REST more accessible for external consumers.
Key Takeaway: Choose RPC when your API is action-focused, requires high performance, or benefits from strong typing in controlled environments. Choose REST for resource-centric, public-facing, or cache-heavy scenarios.