Microservices and Scaling Strategy
A distributed system can always be scaled in a 3D space, and we need to scale the distributed system to manage the load and having high availability of the website.
Join the DZone community and get the full member experience.Join For Free
I have heard the below questions many times
'How do I scale Microservices?'
'What type of Scaling does Microservices unlock?'
So, I thought to write a crisp article on the Scaling.
A distributed system can always be scaled in a 3D space, i.e., X-axis, Y-axis, and Z-axis, and we need to scale the distributed system to manage the load and having high availability of the website, and of course, managing the cost in an efficient manner by maintaining servers/other resources optimum way.
The 3 Axes
X-axis offers to spawn the environment based on the load, the old way of scaling distributed system that is behind a load balancer increase instances. It offers infinite scaling.
Y-axis offers scaling by isolated the business functionality, aka, functional decomposition, so if a function has more load/usage/priority than the other functionality, we only scale that function and managing the cost of resources optimized manner. It offers infinite scaling of a particular function, however, total decomposition is finite but can be increased as function increases.
Z-axis offers scaling through partitioning via business parameters, it allows the organization to serve premium customers or special requests or geodiversity in a dedicated cluster of servers, etc. It also can be infinitely scaled based on the business parameters. However, total parameter rules are finite but can be increased as you add more rules to it.
Keep one thing in mind, Monoliths also distributed and it is also logically functionally decomposed through multi-module projects or package structure, etc., but while deploying it packages as a single artifact ear or jar, so it does not unlock the Y-axis. As it does not offer a physical functional decomposition, each function does not have its own program space or environment (per function per container/server). Microservices by nature unlock that so, Microservices adopted the full potential of 3D space scaling.
Microservices uses 3 types of scaling following the art of scaling principles:
Y-axis Scaling: Microservices' main focus is to do the functional decomposition and it does it very well, each function wrapped by one or more microservices, so If one feature in your system dealing with high loads you can only scale up that functions only, not touching the other services.
Z-axis Scaling: It helps you to partition your data, zone wise if your business distributed geologically you can put data centers based on Zones and that datacenter will serve the request for that zone, it helps serve your request quickly, and if loads of zones increases you can scale only that zones, not only that you can apply logic based on request param and send it to separate servers, say you have premium customers you want to serve them quickly you can do that.
X-axis Sclalling: You can spawn multiple instances of Microservices based on the loads; you can use Cloud or can spawn by containers. It will give you the whole environment, not only artifacts that save your boot uptime.
Try to view Microservices Scaling in a hierarchy order: it starts with Y-axis scaling, then each Microservice can be scaled Via X and Z axis. You can adopt all types of scaling through Microservices architecture.
Published at DZone with permission of Shamik Mitra, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.