Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a REST API in the context of microservices?
A REST API is a way for microservices to communicate over the internet using simple HTTP methods like GET, POST, PUT, and DELETE. It uses URLs to access resources and exchanges data usually in JSON format.
Click to reveal answer
intermediate
Why use REST APIs between microservices instead of direct database access?
REST APIs provide a clear boundary between services, allowing each to manage its own data and logic. This reduces tight coupling, improves security, and makes the system easier to maintain and scale.
Click to reveal answer
beginner
What HTTP methods are commonly used in REST APIs and what do they represent?
Common HTTP methods are GET (read data), POST (create data), PUT (update data), and DELETE (remove data). These map to basic actions on resources in REST APIs.
Click to reveal answer
intermediate
How does statelessness in REST APIs help microservices?
Statelessness means each request from a client to a service contains all information needed to understand and process it. This makes services easier to scale and recover because they don't rely on stored session data.
Click to reveal answer
advanced
What are some common challenges when designing REST APIs between microservices?
Challenges include handling network failures, versioning APIs without breaking clients, securing communication, managing data consistency, and ensuring good performance under load.
Click to reveal answer
Which HTTP method is typically used to update an existing resource in a REST API?
AGET
BPOST
CPUT
DDELETE
✗ Incorrect
PUT is used to update an existing resource or create it if it does not exist.
What does it mean that REST APIs are stateless?
AEach request contains all information needed to process it
BThey keep connections open permanently
CThey require cookies to work
DThey store user sessions on the server
✗ Incorrect
Stateless means the server does not store client context between requests.
Why is using REST APIs better than direct database access between microservices?
AREST APIs are slower but easier to hack
BREST APIs create tight coupling between services
CDirect database access is more secure
DREST APIs provide clear boundaries and improve maintainability
✗ Incorrect
REST APIs help keep services independent and easier to manage.
Which data format is most commonly used to exchange data in REST APIs?
AJSON
BCSV
CXML
DYAML
✗ Incorrect
JSON is lightweight and easy to use, making it the most common format.
What is a common way to handle different versions of a REST API?
AChange the API without notice
BUse version numbers in the URL or headers
COnly support one version forever
DUse different HTTP methods for versions
✗ Incorrect
Versioning in URLs or headers allows clients to choose which API version to use.
Explain how REST APIs enable communication between microservices and why statelessness is important.
Think about how each request carries all needed info and how services talk over HTTP.
You got /5 concepts.
Describe common challenges when designing REST APIs for microservices and how to address them.
Consider what can go wrong when services talk and how to keep them working smoothly.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of using a REST API between microservices?
easy
A. To allow services to communicate over HTTP using standard methods
B. To store data permanently in a database
C. To run services on the same machine only
D. To replace all backend logic with frontend code
Solution
Step 1: Understand REST API role in microservices
REST APIs enable communication between independent services using HTTP methods like GET, POST, PUT, DELETE.
Step 2: Identify the correct purpose
Storing data or running services on the same machine are not the main goals of REST APIs; they focus on communication.
Final Answer:
To allow services to communicate over HTTP using standard methods -> Option A
Quick Check:
REST API = communication over HTTP [OK]
Hint: REST APIs connect services via HTTP methods [OK]
Common Mistakes:
Confusing REST API with database storage
Thinking REST APIs run services locally only
Assuming REST replaces backend logic
2. Which HTTP method is typically used to update an existing resource in a REST API between microservices?
easy
A. GET
B. PUT
C. POST
D. DELETE
Solution
Step 1: Recall HTTP methods and their purposes
GET retrieves data, POST creates new data, PUT updates existing data, DELETE removes data.
Step 2: Match method to update action
Updating a resource is done with PUT, which replaces or modifies the resource at the given URL.
Final Answer:
PUT -> Option B
Quick Check:
Update = PUT [OK]
Hint: PUT method updates resources in REST APIs [OK]
Common Mistakes:
Using GET to update data
Confusing POST with update instead of create
Using DELETE to update resources
3. Consider this REST API call between two services:
GET /users/123
What is the expected result of this request?
medium
A. Retrieve details of the user with ID 123
B. Create a new user with ID 123
C. Delete the user with ID 123
D. Update the user with ID 123
Solution
Step 1: Analyze the HTTP method and URL
The method is GET, which is used to retrieve data. The URL targets user with ID 123.
Step 2: Determine the action based on method
GET requests fetch data without changing it, so it retrieves user details.
Final Answer:
Retrieve details of the user with ID 123 -> Option A
Quick Check:
GET /users/123 = retrieve user data [OK]
Hint: GET fetches data, not modifies it [OK]
Common Mistakes:
Thinking GET creates or deletes data
Confusing URL path with action
Assuming GET updates resources
4. A microservice sends a POST request to another service's REST API but receives a 405 Method Not Allowed error. What is the most likely cause?
medium
A. The request body is missing required fields
B. The URL endpoint does not exist
C. The HTTP method POST is not supported by the endpoint
D. The server is down
Solution
Step 1: Understand 405 Method Not Allowed meaning
This error means the server recognizes the URL but does not allow the HTTP method used.
Step 2: Match error to cause
If POST is not supported on that endpoint, the server rejects it with 405. Other issues cause different errors.
Final Answer:
The HTTP method POST is not supported by the endpoint -> Option C
Quick Check:
405 error = method not allowed [OK]
Hint: 405 means method not allowed on endpoint [OK]
Common Mistakes:
Confusing 405 with 404 (not found)
Assuming missing fields cause 405
Thinking server down causes 405
5. You design two microservices: Service A calls Service B's REST API to get user data. To improve scalability and reduce latency, which design choice is best?
hard
A. Service A calls Service B synchronously for every user request
B. Service A and B share a database to avoid API calls
C. Service B pushes user data to Service A via REST POST requests
D. Service A caches user data locally and refreshes periodically
Solution
Step 1: Evaluate synchronous calls impact
Calling Service B synchronously for every request adds latency and load, reducing scalability.
Step 2: Consider caching benefits
Caching user data locally in Service A reduces calls to Service B, improving response time and scalability.
Step 3: Assess other options
Service B pushing data is complex and not typical REST usage; sharing a database breaks microservice independence.
Final Answer:
Service A caches user data locally and refreshes periodically -> Option D
Quick Check:
Caching improves scalability and latency [OK]
Hint: Cache data locally to reduce cross-service calls [OK]