"With micro-messaging service to improve service reliability."

 

Preface:

In the past, it is easy to pass: Remove the bare metal server, install all the required software, add all the application code, the data load up a series of procedures to deploy the single application (monolithic application). Because all components are concentrated on a single server, so this application will not only be able to handle a larger flow, and very easy to manage and deploy.

However, the big problem with this type of application is inefficient. For example, you must first estimate of the peak load, coupled with adequate performance to server. But having such resources will configure the server is idle under normal load, and even cause a lot of waste in small loads.

In addition, we may need pain to be extended on the resources of the server manually. And if a component requires more resources than the server itself, it must be forced to shut down the entire machine upgrade, which is bound to affect all other components. Therefore, it is true that there is still a unique bare-metal server application scenarios, but they have gradually been replaced by a new micro-services architecture.

What is a micro-service architecture?

Micro Services Architecture is a software development technology, will build a set of application services into loosely coupled. These services have refined a lightweight protocol characteristics, not only improves the modular nature of the application, and easy to be understood, developed and tested. Small autonomy of the team that they can independently by using a parallel development, deployment, and expand their services. In addition, the micro-architecture-based services can also support the continued delivery and deployment (Source: Wikipedia,  https://en.wikipedia.org/wiki/Microservices  ).

Thus, we are no longer limited to the one server to deploy all the code and data assets database, but each tag will be divided into different groups, and operate independently of each other. Therefore, we can not only by setting a specific storage area, to allow only part of the code responsible for uploading, operation, save the image; can also create a specific database, to make part of the code is only responsible for checks and create session. In addition, you can either use a particular block of code to handle the new user's posts, you can use another block of code (or service), to check whether there have been inappropriate remarks. A database can be used to store all kinds of comments, and the other libraries can be used to search by keyword.

So, what practical benefits it has a micro-services?

· First, each micro-services can be based on usage, stretching to adjust capacity in proportion to save valuable resources and services.

· Second, we can better connect people with the developer responsible for the database, backend code writers, and UI / UX personnel decile leave to.

· Moreover, since each of the services are able to work independently of each other, the load will not affect the size of a component to another component. Similarly, the upgrade of a component does not need to involve splitting for another component.

Visible, the various components are able to achieve higher uptime.

Limitations of micro Services Architecture

Everything advantages and disadvantages, one of the main disadvantages of micro-services architecture is: the overall security of the normal application run time. Since we will be dispersed throughout the application to the various micro-services, although the reliability of the individual components increased, but at the cost to the overall reliability of the application brings uncertainty.

In the single bare metal applications, regardless of the network, hard drive, memory, or other aspects of the problem, the application will interrupt the overall service. Therefore, if the supplier commitment to you 99.5% uptime, then you only need to worry about how you can improve at 99.5% basis. However, if you are using a micro-service architecture, each component will have their uptime baseline. For example, your application uses 10 services, while the overall proportion of each service uptime of 99.5%, the normal operation of the overall proportion of 99.5% of the power of 10 = 95.0%.

Does this mean that micro Services Architecture is not good? Not necessarily. This simply means that in addition to benefit from the benefits of the micro service brought outside, developers need to take other measures to protect their applications, and reduce the potential for downtime. Quite interesting is that here we can introduce another micro service - Ali cloud messaging services (Alibaba Cloud's Message Service, see  https://www.alibabacloud.com/product/message-service  ).

What is Ali cloud messaging services?

Ali cloud messaging service is a distributed message queuing and notification services. It supports concurrent operation, help transport messages between applications and decoupling system. Ali cloud message service enables the user to transfer data, to implement various complex tasks between distributed applications, and further constructed with an application fault tolerance and the decoupling.

How message service uptime?

To better understand how to improve the reliability of messaging services is, let's discuss a typical group chat application. Let's say you've built a fan like group chat application -Sports App, which contains the various chat groups, such as: Chelsea, Barcelona, ​​Real Madrid, Bayern Munich, Manchester United and other popular soccer club.

Anyone can publish to any group in the message, and can subscribe to their favorite club team to inform other fans informed of news published. Obviously, you give full consideration to its scalability should develop such applications. By continuously monitoring its growth, you can filter out all kinds of inappropriate speech and image messages, and provides news search function. Therefore, in order to meet these requirements, you are offered a range of cloud services for each function. Final system architecture as shown below:

 

In the case of setting, when users want to publish new messages to a group, the rear end of the Sports App receives the request and then passes it to the micro-services, and ultimately informs the user transfer success receipt. Specific procedures:

  • First, check whether the user is entitled to the rear end of publish messages to particular groups, while filtering out non-standard HTML tags, or other hazard input parameters.
  • Then, the application of artificial intelligence through a number of related services to check compliance messages, checking if passed, will continue to save the messages to a cloud database.
  • Next, the program passes the message to the optimization search based data storage services Elasticsearch like. Sports App may decide to add a separate service data analysis to analyze which mentioned more often in the name of the club and other features.
  • Moreover, developers can also be applied by addition to the monitor, for implementation of the request.
  • Finally, Sports App will remind all members, this news has been posted to the target group.

As we have seen, the whole process may be a bit lengthy, even if they are completed within a few milliseconds, entire message transmission chain still contains many potential points of failure. Moreover, once a particular service in the chain fails, then the whole process of transfer requests will be wrong.

让我们再重新回顾一下上述对于请求检查的业务逻辑。其实,对于发布消息的用户来说,他既不会关心后台所执行的身份验证,又不太会注意消息的合规性,更不必知道消息是如何存储的,以及后台是如何保证每个组成员都能够收到新的消息。他只需关心自己的消息最终能否发布到目标组中。

因此,让我们来通过使用消息服务(Message Service),来调整技术栈,以满足此类需求。新的技术栈所对应的系统架构如下图所示:

 

在上述架构中,当用户发布新的消息时,我们需要做的只是将其传递给消息服务。如果顺利完成,该消息会返回给用户成功的回执。全程只需几毫秒,这对应用方和用户端来说都是非常好的使用体验。

而在单独的请求中,应用服务会代替用户将对应的信任凭据和参数回传到Sports的后端服务器上。在此过程中,如果发生任何错误的话,我们只需事先设置好标准的错误响应代码,如“503:服务不可用”便可。同时,消息服务还会反复地重试该请求,直至它被成功传递、或7天后默认超时。

当然,您完全不必止步于此。通过使用消息服务,您可以更进一步地解决诸如:授权检查、或消息合规性检查等方面的问题。籍此,您可以逐步提高自己的应用所使用到的各项微服务的可靠性。

获取资料:

本次给大家分享一些学习资料,里面包括:(高可用、高并发、高性能及分布式、Jvm性能调优、Spring源码,MyBatis,Netty,Redis,Kafka,Mysql,Zookeeper,Tomcat,Docker,Dubbo,Nginx等多个知识点的架构资料)以及Java进阶学习路线图。

领取方式,加微信号  weixing99ting  验证消息备注:资料 ,即可获取。
最后,祝大家早日学有所成!

Guess you like

Origin www.cnblogs.com/L10086/p/11432402.html