0% found this document useful (0 votes)
5 views12 pages

RPC Vs REST - Difference Between API Architectures - AWS

The document compares Remote Procedure Call (RPC) and REST API architectures, highlighting their differences and similarities. RPC allows developers to call remote functions as if they were local, while REST focuses on resource manipulation through standard HTTP methods. REST is typically stateless and supports multiple data formats, whereas RPC can be stateful or stateless and has a fixed data format determined by the server.

Uploaded by

RISHAV RAJ
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views12 pages

RPC Vs REST - Difference Between API Architectures - AWS

The document compares Remote Procedure Call (RPC) and REST API architectures, highlighting their differences and similarities. RPC allows developers to call remote functions as if they were local, while REST focuses on resource manipulation through standard HTTP methods. REST is typically stateless and supports multiple data formats, whereas RPC can be stateful or stateless and has a fixed data format determined by the server.

Uploaded by

RISHAV RAJ
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

What is Cloud Computing? / Cloud Computing Concepts Hub / Application Integration

What’s the Difference Between RPC and REST?

Create an AWS Account

Explore Free Application Integration Offers Check out Application Integration Services
View free offers for Application Integration services in the cloud Innovate faster with the most comprehensive set of Application Integration services

Hi, I can connect you with an AWS


representative or answer questions you
have on AWS.
Browse Application Integration Trainings

[Link] 1/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

Get started on Application Integration training with content built by AWS experts

Read Application Integration Blogs


Read about the latest AWS Application Integration product news and best practices

What's the difference between RPC and REST?


Remote Procedure Call (RPC) and REST are two architectural styles in API design. APIs are mechanisms that enable two software components to
communicate with each other using a set of definitions and protocols. Software developers use previously developed or third-party components to
perform functions, so they don’t have to write everything from scratch. RPC APIs allow developers to call remote functions in external servers as if
they were local to their software. For example, you can add chat functionality to your application by remotely calling messaging functions on
another chat application. In contrast, REST APIs allow you to perform specific data operations on a remote server. For example, your application
could insert or modify employee data on a remote server by using REST APIs.

Read about APIs »

Read about RESTful APIs »

What are the similarities between RPC and REST?


Remote Procedure Call (RPC) and REST are both ways to design APIs. APIs are essential in modern web design and other distributed systems. They
allow two separate, distributed applications or services to communicate without knowing the internals of how the other one works. These two
applications or services may have little to do with one another except for a small data exchange.

[Link] 2/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

APIs are also a common mechanism for the backend of a program (the logic component) to communicate with the frontend of a program (the
display component). When you design web pages and web applications with APIs instead of tightly coupled integration, you ensure they can scale
and change with less code rewriting.

Next, we discuss other similarities between RPC and REST APIs.

Abstraction

While network communications are the main aim of APIs, the lower-level communications themselves are abstracted away from API developers.
This allows developers to focus on function rather than technical implementation.

Communication

Both REST and RPC use HTTP as the underlying protocol. The most popular message formats in RPC and REST are JSON and XML. JSON is favored
due to its readability and flexibility.

Cross-language compatibility

Developers can implement a RESTful or RPC API in any language they choose. So long as the network communication element of the API conforms
with the RESTful or RPC interface standard, you can write the rest of the code in any programming language.

Architecture principles: RPC vs. REST


In Remote Procedure Call (RPC), the client makes a remote function (also known as method or procedure) call on a server. Typically, one or more
data values are passed to the server during the call.

In contrast, the REST client requests the server to perform an action on a specific server resource. Actions are limited to create, read, update, and
delete (CRUD) only and are conveyed as HTTP verbs or HTTP methods.

RPC focuses on functions or actions, while REST focuses on resources or objects.

[Link] 3/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

RPC principles

Next, we discuss some principles that RPC systems typically follow. However, these principles are not standardized like REST.

Remote invocation

An RPC call is made by a client to a function on the remote server as if it were called locally to the client.

Passing parameters

The client typically sends parameters to a server function, much the same as a local function.

Stubs

Function stubs exist on both the client and the server. On the client side, it makes the function call. On the server, it invokes the actual function.

REST principles

REST principles are standardized. A REST API must follow these principles to be classified as RESTful.

Client-server

The client-server architecture of REST decouples clients and servers. It treats them each as independent systems.

Stateless

The server keeps no record of the state of the client between client requests.

Cacheable

The client or intermediary systems may cache server responses based on whether a client specifies that the response may be cached.

Layered system

[Link] 4/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

Intermediaries can exist between the client and the server. Both client and server have no knowledge of them and operate as if they were directly
connected.

Uniform interface

The client and server communicate via a standardized set of instructions and messaging formats with the REST API. Resources are identified by their
URL, and this URL is known as a REST API endpoint.

How they work: RPC vs. REST


In Remote Procedure Call (RPC), the client uses HTTP POST to call a specific function by name. Client-side developers must know the function name
and parameters in advance for RPC to work.

In REST, clients and servers use HTTP verbs like GET, POST, PATCH, PUT, DELETE, and OPTIONS to perform options. Developers only need to know
the server resource URLs and don't have to be concerned with individual function names.

The following table shows the type of code the client uses to perform similar actions in RPC and REST.

Action RPC REST Comment

POST /addProduct HTTP/1.1 POST /products HTTP/1.1

HOST: [Link] HOST: [Link]


Adding a new
product to a product RPC uses POST on function, and REST uses POST on URL.
Content-Type: application/json Content-Type: application/json
list

{"name": "T-Shirt", "price": {"name": "T-Shirt", "price":


"22.00", "category": "Clothes"} "22.00", "category": "Clothes"}

[Link] 5/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

POST /getProduct HTTP/1.1

HOST: [Link] GET /products/123 HTTP/1.1 RPC uses POST on function and passes parameter as JSON
Retrieving a
object. REST uses GET on URL and passes parameter in
product’s details
Content-Type: application/json HOST: [Link] URL.

{"productID": "123”}

POST /updateProductPrice
HTTP/1.1 PUT /products/123 HTTP/1.1

HOST: [Link] HOST: [Link] RPC uses POST on function and passes parameter as JSON
Updating a
object. REST uses PUT on URL and passes parameter in
product’s price
Content-Type: application/json Content-Type: application/json URL and as JSON object.

{"productId": "123", "newPrice": {"price": "20.00"}


"20.00"}

POST /deleteProduct HTTP/1.1

DELETE /products/123
HOST: [Link] RPC uses POST on function and passes parameter as JSON
HTTP/1.1
Deleting a product object. REST uses DELETE on URL and passes parameter in
Content-Type: application/json URL.
HOST: [Link]

{"productId": "123""}

Key differences: vs. REST

[Link] 6/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

Remote Procedure Call (RPC) and REST are both ways to design corresponding client and server system interfaces for communication over the
internet. However, the structure, implementation, and underlying principles differ. Systems designed with REST are known as RESTful APIs, whereas
systems designed with RPC are simply RPC APIs.

Next, we give some more differences.

Time of development

RPC was developed in the late 1970s and early 1980s, while REST was a term first coined by computer scientist Roy Fielding in 2000.

Operational format

A REST API has a standardized set of server operations because of HTTP methods, but RPC APIs don’t. Some RPC implementations provide a
framework for standardized operations.

Data passing format

REST can pass any data format and multiple formats, like JSON and XML, within the same API.

However, with RPC APIs, the data format is selected by the server and fixed during implementation. You can have specific JSON RPC or XML RPC
implementations, and the client has no flexibility.

State

In the context of APIs, stateless refers to a design principle where the server does not store any information about the client's previous interactions.
Each API request is treated independently, and the server does not rely on any stored client state to process the request.

REST systems must always be stateless, but RPC systems can be stateful or stateless, depending on design.

When to use: RPC vs. REST

[Link] 7/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

Remote Procedure Call (RPC) is typically used to call remote functions on a server that require an action result. You can use it when you require
complex calculations or want to trigger a remote procedure on the server, with the process hidden from the client.

Here are actions where RPC is a good option:

Take a picture with a remote device’s camera

Use a machine learning algorithm on the server to identify fraud

Transfer money from one account to another on a remote banking system

Restart a server remotely

A REST API is typically used to perform create, read, update, and delete (CRUD) operations on a data object on a server. This makes REST APIs a
good fit for cases when server data and data structures need to be exposed uniformly.

Here are actions where a REST API is a good option:

Add a product to a database

Retrieve the contents of a music playlist

Update a person’s address

Delete a blog post

Why did REST replace RPC?


While REST web APIs are the norm today, Remote Procedure Call (RPC) hasn’t disappeared. A REST API is typically used in applications as it is easier
for developers to understand and implement. However, RPC still exists and is used when it suits the use case better.

Modern implementations of RPC, such as gRPC, are now more popular. For some use cases, gRPC performs better than RPC and REST. It allows
streaming client-server communications rather than the request-and-respond data exchange pattern.

[Link] 8/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

Summary of differences: RPC vs. REST

RPC REST

A system allows a remote client to call a procedure A set of rules that defines structured data exchange between a client and a
What is it?
on a server as if it were local. server.

Used for Performing actions on a remote server. Create, read, update, and delete (CRUD) operations on remote objects.

When requiring complex calculations or triggering a


Best fit When server data and data structures need to be exposed uniformly.
remote process on the server.

Statefulness Stateless or stateful. Stateless.

Data passing In a consistent structure defined by the server and In a structure determined independently by the server. Multiple different
format enforced on the client. formats can be passed within the same API.

How can AWS support your API requirements?


Amazon Web Services (AWS) has a range of services and tools to help API designers build, run, and manage API-based modern applications and
services. For more information, read about building modern applications on AWS.

Here are examples of AWS services that can help you meet your API requirements:

[Link] 9/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

Amazon API Gateway allows developers to create, publish, and manage APIs at scale. With API Gateway, you can build REST APIs optimized for
containerized microservice architectures and web applications.

Elastic Load Balancing (ELB) distributes network traffic to improve application scalability. It can route and load balance gRPC traffic between
microservices or between gRPC-enabled clients and services. This allows for seamless gRPC traffic management in software architectures
without changing any underlying infrastructure for customers’ clients or services.

Amazon Virtual Private Cloud (Amazon VPC) Lattice is an application networking service that consistently connects, monitors, and secures
communications between your services. Scale compute and network resources automatically to support high-bandwidth HTTP, HTTPS, and
gRPC workloads.

Get started with REST APIs and Remote Procedure Call (RPC) APIs on AWS by creating an account today.

Next Steps with AWS

Learn how to get started with RPC on AWS

Learn how to get started with REST on AWS

[Link] 10/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

Resources for AWS Developers on AWS Help


Sign In to the Console
Getting Started Developer Center Contact Us

Learn About AWS Training and Certification SDKs & Tools Get Expert Help
AWS Solutions Library .NET on AWS File a Support Ticket
What Is AWS?
Architecture Center Python on AWS AWS re:Post
What Is Cloud Computing?
Product and Technical FAQs Java on AWS Knowledge Center
AWS Accessibility
Analyst Reports PHP on AWS AWS Support Overview
AWS Inclusion, Diversity & Equity
AWS Partners JavaScript on AWS Legal
What Is DevOps?
AWS Careers
What Is a Container?
What Is a Data Lake?
What is Generative AI?
AWS Cloud Security
What's New
Blogs
Press Releases

Create an AWS Account

  
   

[Link] 11/12
17/07/2024, 18:43 RPC vs REST - Difference Between API Architectures - AWS

Amazon is an Equal Opportunity Employer: Minority / Women / Disability / Veteran / Gender Identity / Sexual Orientation / Age.

Language
‫| عربي‬
Bahasa Indonesia |
Deutsch |
English |
Español |
Français |
Italiano |
Português |
Tiếng Việt |
Türkçe |
Ρусский |
ไทย |
日本語 |
한국어 |
中文 (简体) |
中文 (繁體)

Privacy
|
Accessibility
|
Site Terms
|
Cookie Preferences
|
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.

[Link] 12/12

You might also like