Read the story between Spring Boot, microservice architecture and big data governance in one article

Microservice Architecture

The birth of microservices is not accidental. It is a product born under the promotion of multiple factors such as the rapid development of the Internet, the rapid changes in technology, and the inability of traditional architectures to adapt to rapid changes. Products in the Internet era usually have two types of characteristics: rapid changes in demand and huge user groups. In this case, how to build a flexible and easily scalable system from the perspective of system architecture to quickly respond to changes in demand; With the increase of users, how to ensure the scalability and high availability of the system has become a challenge for the system architecture.

If we still follow the previous traditional development mode, it is difficult to develop a large and comprehensive system to meet the market demand for technology. At this time, the idea of ​​divide and conquer was proposed, so we developed from a separate architecture to a distributed architecture, and then from distributed architecture. As the architecture develops to SOA architecture, services are continuously split and decomposed, and the granularity is getting smaller and smaller, until the birth of microservice architecture.

Microservice architecture is the inheritance of SOA architecture, but one of the most essential differences is that microservices are truly distributed and decentralized. Putting all the "thinking" logic including routing, message parsing, etc. inside the service, removing a unified ESB, and light communication between services is a more thorough split than SOA. The emphasis of the microservice architecture is that the business system needs to be completely componentized and serviced. The original single business system will be split into multiple small applications that can be independently developed, designed, operated and maintained. Services complete the interaction and integration.

Beginning around 2009, Netflix completely redefined its application development and operations model, taking the first steps of microservice exploration until an article by Martin Fowler in March 2014  Microservices  in a more accessible form Define what a microservice architecture is for everyone. Martin Fowler expounded the idea of ​​the microservice architecture in the article, thinking that the microservice architecture is an architectural pattern, which advocates dividing a single application into a set of small services, and the services coordinate and cooperate with each other to provide users with the ultimate value. .

Each service runs in its own independent process, and the services communicate with each other using a lightweight communication mechanism (usually an HTTP-based RESTful API). Each service is built around a specific business and can be independently deployed to production environments, production-like environments, etc. In addition, a unified and centralized service management mechanism should be avoided as much as possible. For a specific service, appropriate languages ​​and tools should be selected to build it according to the business context.

Microservice Architecture and Data Governance

With the implementation of the microservice architecture, people find that although the microservice architecture improves the development model, it also introduces some problems. Among all these problems, the most important one that will soon be faced is the problem of data. In the microservice architecture, we emphasize complete componentization and serviceization. Each microservice can be deployed and put into production independently, which means that many microservices have their own independent databases.

After the entire business data is dispersed in various sub-services, it will bring two most obvious problems: 1. The business management system queries the complete data, such as paging query, multi-condition query, etc. How to integrate the data after it is divided? 2. How to further analyze and mine the data? These requirements may require analysis of the full amount of data, and the analysis cannot affect the current business.

In terms of technical solutions, we generally have two options to deal with these problems, the first is to process data online, and the second is to process data offline.

The solution for online data processing is to follow the standard interface of the microservice, and the backend needs to call the interface provided by a microservice to obtain the data of the system that needs it. The back-end management platform goes to different micro-service systems to obtain data according to the needs of the front-end, and then processes the returned data and returns the data. This scheme has two drawbacks:

1) On the one hand, the microservice data side needs to provide a data interface, on the other hand, the data user needs to write the calling method, and the caller needs to write a lot of code for data processing;

2) When calling data for each microservice, it will affect the normal business processing performance of the microservice.

The offline data processing solution is to synchronize the business data to another database in quasi-real time, and perform data integration processing during the synchronization process to meet the needs of the business side for data. After the data is synchronized, another service interface is provided. Responsible for exporting data to the outside world. This scheme has two characteristics:

1) The data synchronization scheme is the key, there are many technical options, how to choose the technical scheme that suits the company's business;

2) Offline data processing has no impact on the normal business processing of microservices.

Both schemes have been implemented in my previous work, and I personally prefer the second scheme.

MongoDB and data analytics

MongoDB is called the most developer-friendly database. It no longer emphasizes the rows and columns in traditional relational databases. The entire table can be regarded as a Json document. Similar to relational database database (DataBase), collection (Collection), document object (Document).

MongoDB is one of the most popular non-relational databases at present. MongoDB ranks fifth in the latest database rankings, and ranks first among all non-relational databases. It is widely used in Internet companies at home and abroad.

The biggest feature of MongoDB is that the query language it supports is very powerful. Its syntax is somewhat similar to an object-oriented query language. It can almost realize most of the functions similar to single-table query in relational databases, and it also supports indexing of data. MongoDB's implementation of high availability and read-write load balancing is very simple and friendly. MongoDB comes with the concept of replica sets. By designing appropriate replica sets and drivers, high availability and read-write load balancing can be easily achieved.

These features of MongoDB are very convenient for high-performance querying of data. MongoDB supports Aggregate and Mapreduce to handle large-scale data analysis using the divide-and-conquer concept. Spring Boot's support for MongoDB is very friendly. It is very convenient to use Spring Boot to process queries and operations on MongoDB. Spring Boot also provides component packages to support the use of MongoDB.

MongoDB 4.0 announced that it will officially support ACID transactions, and the imagination of MongoDB in the future is even more huge! So MongDB + Spring Boot is one of the ideal choices for data analysis in microservice architecture.

Let's talk about Spring Boot again

Spring Boot is a new framework provided by the Pivotal team, designed to simplify the initial setup and development of new Spring applications. The framework uses a specific way to configure, so that developers no longer need to define boilerplate configuration. Using Spring Boot can greatly simplify the development mode. All the common frameworks you want to integrate have corresponding component support.

Spring Boot is developed based on Spring. Spirng Boot itself does not provide the core features and extension functions of the Spring framework, but is only used to quickly and agilely develop a new generation of applications based on the Spring framework. In other words, it is not a solution to replace Spring, but a tool that is tightly integrated with the Spring framework to enhance the Spring developer experience. At the same time, it integrates a large number of commonly used third-party library configurations (such as Redis, MongoDB, Jpa, RabbitMQ, Quartz, etc.). These third-party libraries in Spring Boot applications can be used out of the box with almost zero configuration. Most Spring Boot applications All require only a very small amount of configuration code, and developers can focus more on business logic.

Spring Boot has been sought after by the open source community as soon as it was launched. Spring Boot officially provides many Starters to facilitate the integration of third-party products. Many mainstream frameworks have also been actively integrated, such as Mybatis. Spring official attaches great importance to the development of Spring Boot, and it is recommended and introduced on the homepage of Spring's official website, which is one of the key development projects of Spring official.

Spring Boot itself is developing very fast. Since Spring Boot 1.0 was released in April 2014, the version has been updated very frequently. When I used it in 2016, it was 1.3.X. Now Spring Boot has released Spring Boot 2.0, Spring Boot 2.0 integration Many latest and excellent technologies and new features have been introduced, and the API of Spring Boot 1.0 has been greatly optimized. As soon as Spring Boot was launched, it quickly became a popular technology. This conclusion can also be seen from the following figure:

The above picture shows the Baidu Index of Spring Boot from 2014 to 2018. It can be seen that the launch of Spring Boot 2.0 has triggered a search peak.

Spring Boot and Microservice Architecture

With the continuous development of Spring, more and more fields are involved. Project integration development needs to cooperate with various files, which gradually becomes less easy to use and simple, which violates the original concept and is even called configuration hell. Spring Boot is a development framework that was abstracted from such a background. The purpose is to make it easier for everyone to use Spring and integrate various commonly used middleware and open source software. On the other hand, when Spring Boot was born, As the concept of microservices is slowly brewing, Spring Boot's research and development integrates the concept of microservices architecture and realizes the technical support for the implementation of microservices architecture in the Java field.

As a brand new framework, Spring Boot comes from the Spring family, so it has all the functions that Spring has, and it is easier to use; Spring Boot, with the core idea of ​​convention over configuration, helps us make a lot of settings by default. Most Spring Boot Boot applications require very little Spring configuration. Spring Boot has developed a lot of application integration packages and supports most open source software, allowing us to integrate other mainstream open source software at a very low cost.

Spring Boot features :

  • Build a project in seconds using the Spring Project Bootstrap page
  • It is convenient to export various forms of services, such as REST API, WebSocket, Web, Streaming, Tasks
  • Very clean security policy integration
  • Supports relational and non-relational databases
  • Supports runtime embedded containers, such as Tomcat, Jetty
  • Powerful development package, support hot start
  • Automatically manage dependencies
  • Built-in application monitoring
  • Support various IEDs, such as IntelliJ IDEA, NetBeans

These features of Spring Boot are very convenient and fast to build independent microservices. Therefore, we use Spring Boot to develop projects, which will bring great convenience to our traditional development. It can be said that if you have used Spring Boot to develop projects, you will no longer be willing to develop projects in the previous way.

To sum up, using Spring Boot can bring us at least the following improvements :

  • Spring Boot simplifies coding. Spring Boot provides a wealth of solutions to quickly integrate various solutions to improve development efficiency.
  • Spring Boot makes configuration simple. Spring Boot provides a wealth of Starters, and integration of mainstream open source products often only requires simple configuration.
  • Spring Boot makes deployment easier. Spring Boot itself has a built-in startup container, and only one command is needed to start the project. It is very easy to realize automatic operation and maintenance with Jenkins and Docker.
  • Spring Boot makes monitoring simple. Spring Boot comes with monitoring components, and Actuator is used to easily monitor the status of services.

To sum up, Spring Boot is the best microservice architecture landing technology in the Java field.

The entanglement between the three

After understanding the microservice architecture, Spring Boot, and big data governance, we found such an interesting thing: the microservice architecture is an architectural idea and the inevitable result of the continuous development of the architecture. It has the advantages of flexible construction, easy expansion, rapid application, Features such as scalability and high availability; the introduction of the micro-service architecture idea has higher requirements for technology. In this context, Spring Boot was born, and Spring Boot was born into a famous family, standing at a relatively high level from the very beginning. Starting from the starting point, and after several years of development, the ecology is sufficiently complete, and Spring Boot has deservedly become the most popular technology in the Java field.

Under the microservice architecture, data is separated into N independent microservices. How to deal with the query and analysis of large amounts of data by the market and business becomes very urgent. Using Spring Boot and MongoDB can easily solve this problem, through technical means Synchronize the data split into N microservices into the MongoDB cluster, and perform data cleaning during the synchronization process to meet the company's various business needs. Spring Boot's support for MongoDB is very friendly. On the one hand, Spring Data technology pre-generates many common methods for easy use. On the other hand, Spring Boot encapsulates the related functions of distributed computing, which allows us to implement statistical queries in a more concise way.

Spring Boot is the best landing technology for microservice architecture in the Java field, and the Spring Boot+MongoDB solution is one of the best solutions for data governance under the microservice architecture.

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324153422&siteId=291194637