Microservice Architecture 简明教程

Microservice Architecture - Scaling

伸缩是将软件分解为不同单元的过程。伸缩还从可伸缩性的角度进行定义。可伸缩性是实现应用程序更多高级功能的潜力。它有助于提高应用程序的安全性、持久性和可维护性。我们在行业中采用了三种类型的伸缩程序。以下是不同的伸缩方法以及相应的真实示例。

Scaling is a process of breaking down a software in different units. Scaling also defines in terms of scalability. Scalability is the potential to implement more advance features of the application. It helps to improve security, durability, and maintainability of the application. We have three types of scaling procedures that is followed in the industries. Following are the different scaling methodologies along with the corresponding real-life examples.

X-Axis Scaling

X 轴伸缩也称为水平伸缩。在此过程中,整个应用程序被细分为不同的水平部分。通常,任何 Web 服务器应用程序都可以进行这种类型的伸缩。考虑一个遵循水平伸缩的普通 MVC 架构,如下图所示。

X-axis scaling is also called as horizontal scaling. In this procedure, the entire application is sub-divided into different horizontal parts. Normally, any web server application can have this type of scaling. Consider a normal MVC architecture that follows horizontal scaling as shown in the following figure.

x axis scaling

例如,我们可以考虑任何 JSP servlet 应用程序。在此应用程序中,控制器控制每个请求,并且它会在必要时与模型通信以生成视图。通常,单体应用程序遵循这种伸缩方法。X 轴伸缩本质上非常基本,并且非常省时。在此方法中,将根据单元负责的不同任务对一款软件进行伸缩。例如,控制器负责控制传入和传出的请求,视图负责向浏览器中的用户表示业务功能,而模型负责存储我们的数据并充当数据库。

As an example, we can consider any JSP servlet application. In this application, the controller controls every request and it will generate view by communicating with the model whenever necessary. Normally, monolithic applications follow this scaling method. X-Axis scaling is very basic in nature and it is very less time consuming. In this methodology, one software will be scaled depending on its different task that the unit is responsible for. For example, the controller is responsible for controlling the incoming and outgoing request, the view is responsible for representing the business functionality to the users in the browser, while the model is responsible to store our data and it works as the database.

Y-Axis Scaling

Y 轴伸缩也称为垂直伸缩,包括任何资源级伸缩。任何 DBaaS 或 Hadoop 系统都可以被认为是 Y 轴伸缩。在此类型的伸缩中,用户请求被重定向并受到限制,方法是实现一些逻辑。

Y-axis scaling is also called as a vertical scaling that includes any resource level scaling. Any DBaaS or Hadoop system can be considered to be Y-axis scaled. In this type of scaling, the users request is redirected and restricted by implementing some logic.

让我们以 Facebook 为例。Facebook 每秒需要处理 179 万用户;因此,控制流量是 Facebook 网络工程师的巨大责任。为了克服任何危险,他们遵循 Y 轴伸缩,其中包括同时运行具有相同应用程序的多个服务器。现在,为了控制这种巨大的流量,Facebook 将所有流量从一个区域重定向到特定服务器,如下图所示。基于区域的这种流量传输在架构语言中称为负载平衡。

Let us consider Facebook as an example. Facebook needs to handle 1.79 million users in every second; hence, controlling the traffic is a huge responsibility of Facebook network engineers. To overcome from any hazard, they follow Y-axis scaling which includes running multiple servers with the same application at the same time. Now in order to control this huge level of traffic, Facebook redirects all the traffic from one region to a specific server, as depicted in the image. This transferring of traffic based on the region is called load balancing in architectural language.

y axis scaling

将资源分解为小型独立业务单元的这种方法称为 Y 轴伸缩。

This method of breaking down resources into small independent business units is known as Y-Axis scaling.

Z-Axis Scaling

X 轴和 Y 轴伸缩很容易理解。然而,一个应用程序也可以在业务级别进行缩放,这称为 Z 轴缩放。以下是将出租车服务应用程序扩展到不同垂直业务单元中的示例。

X- and Y-axis scaling is pretty much easier to understand. However, one application can also be scaled at the business level, which is called as Z-axis scaling. Following is an example of scaling a cab service application in the different verticals of business units.

driver management

Advantages of Scaling

  1. Cost − Proper scaling of a software will reduce the cost for maintenance.

  2. Performance − Due to loose coupling, the performance of a properly scaled software is always better than a non-scaled software.

  3. Load distribution − Using different technologies, we can easily maintain our server load.

  4. Reuse − Scalability of a software also increases the usability of the software.