My team is developing a multi-tier API with scalability and modularity in mind.
ID: 651946 • Letter: M
Question
My team is developing a multi-tier API with scalability and modularity in mind. The public access point of the API is fully REST. However, we are splitting the data access layer as another tier in our architecture and this layer will be on another physical server. We decided that RPC would be a good communication protocol between the public facing API and the private data access layer.
We decided to use RPC over REST for the private communication between our tiers because:
Avoid REST routes duplication between each tier
Transparency in executing code/functions on different servers
The communication is private. With good documentation there shouldn't be any problems for the team to understand the communication protocol.
My question are:
Did we miss advantages or disadvantages in the choice of communication protocol for the private communication between tiers?
What is normally use to communication between tiers in a multi-tier architecture, especially for web APIs?
Explanation / Answer
I am not an expert of scaling applications, but I'll try to answer your question at least partially.
REST has 3 constraints which are about scalability:
stateless constraint
You have to maintain sessions on the client side and on server side you have to authenticate every single request. So you can easily use multiple servers, because you don't need a shared session storage.
cache constraint
You have to send cache headers with every request. So your clients can cache the cacheable responses and so they send less requests.
layered system constraint
Your system components cannot see through the boundaries of the single layer they are in. The upper layer uses the services of the current layer, and the current layer uses the services of the bottom layers, and so on... So you can add load balance, cache, etc... between the client and the service, they won't recognize the existence of those components.
I think by translating REST to RPC the advantages of the layered system constraint are lost for nothing.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.