Can Spring Cloud for data analysis be used in small and medium-sized companies in China?

Good questions must be answered seriously. After reading the question of the subject carefully, I found that this question is very representative. It may be the common idea of ​​the majority of netizens who want to use Spring Cloud but do not know much about Spring Cloud. All aspects of use have been considered, including market, learning, front-end and back-end, testing, configuration, deployment, development, and operation and maintenance. The following is the original problem of the subject:

I want to promote Spring Cloud in the company, but I still have no idea about this technology. Lack of understanding, I drew a brain map and summarized various problems.





Are microservices such a structure?

Front-end or second party -> ng cluster -> zuul cluster -> eureka-server cluster -> service provider cluster

(the second party refers to other business departments)

To understand this problem, you first need to know what is Spring Boot and what is Spring Cloud, And what is the relationship between the two?

What is Spring Boot

Spring Boot simplifies the development of Spring-based applications by creating an independent, production-level Spring application with a small amount of code. Spring Boot provides out-of-the-box setups for the Spring Platform and third-party libraries so you can get started in an organized manner. Most Spring Boot applications require very little Spring configuration. 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.

In my words, Spring Boot is not actually a new framework. It configures many ways to use frameworks by default, just like maven integrates all jar packages, and Spring Boot integrates all frameworks (I don’t know if this analogy is appropriate. ).

The core idea of ​​Spring Boot is that convention is greater than configuration, and everything is done automatically. Using Spring Boot can greatly simplify your development mode. All the common frameworks you want to integrate have corresponding component support.

What is Spring Cloud

Spring Cloud is an ordered collection of a series of frameworks. It uses the development convenience of Spring Boot to subtly simplify the development of distributed system infrastructure, such as service discovery registration, configuration center, message bus, load balancing, circuit breaker, data monitoring, etc., all of which can be done in the Spring Boot development style. to one-click launch and deployment.

Spring does not repeat the manufacture of wheels, it just combines the more mature and practical service frameworks developed by various companies, and re-encapsulates the complex configuration and implementation principles through Spring Boot style. The author has left a set of distributed system development toolkits that are easy to understand, easy to deploy and easy to maintain.

Microservices are service units that can be deployed independently, scaled horizontally, and accessed independently (or have independent databases). Spring Cloud is the big housekeeper of these microservices. After adopting the architecture of microservices, the number of projects will be very large. As a big housekeeper, Cloud needs to provide various solutions to maintain the entire ecosystem.

Spring Cloud is a set of distributed service governance framework. Since it is a set of service governance framework, it does not provide specific functional operations by itself, and focuses more on communication, fusing, and monitoring between services. Therefore, many components are required to support a set of functions.

The relationship between Spring Boot and Spring Cloud

Spring Boot is a set of rapid configuration scaffolding for Spring, which can quickly develop a single microservice based on Spring Boot. Spring Cloud is a cloud application development tool based on Spring Boot; Spring Boot focuses on a single microservice individual that is fast and easy to integrate. Spring Cloud focuses on the global service governance framework; Spring Boot uses the concept that default is greater than configuration. Many integration solutions have been selected for you, and you can not configure it without configuration. A large part of Spring Cloud is based on Spring Boot. Is it based on Spring Boot? Can not.

Spring Boot can leave Spring Cloud to use development projects independently, but Spring Cloud is inseparable from Spring Boot, which is a dependency.

● The relationship between Spring -> Spring Boot > Spring Cloud.

Answer

First of all, these questions asked by the landlord are very good. It is after some thinking. I happened to experience the small and medium-sized companies you mentioned, and they all use Spring Cloud and have been put into production and online. The first company has about 15 technical developers and more than 30 project instances, while the second company has about 100 developers and more than 160 project instances.

To be honest, Spring Boot and Spring Cloud are still developing at a high speed. With the continuous improvement and expansion of the technology ecosystem, there will inevitably be some small bugs, but for the future use of small and medium-sized companies, it can be completely ignored, and solutions can basically be found. Coming down to your question.

1. Market

As far as I know, many well-known Internet companies have already used Spring Cloud, such as Ali and Meituan, but they are all small-scale. Unlike the two companies I have experienced, all business lines embrace Spring Cloud; in addition, Spring Cloud is not a single company. A set of advanced technology, ordinary Java programmers can get started after one to two months, but in the early stage, a relatively proficient person is needed to lead the team.

2.

There . Now that Spring Cloud is becoming more and more popular, various resources are becoming more and more abundant. Check the official documents and examples. Now many excellent blogs are writing related tutorials on Spirng cloud. I collect them here. For some resources related to Spring Boot and Spring Cloud, you can refer to them. If you find blogs, you will find people and organizations.

I specially sorted out the above technologies. There are many technologies that can’t be explained clearly in a few words, so I just asked a friend to record some videos. The answers to many questions are actually very simple, but the thinking and logic behind them are not simple. If you know it, you also need to know why. If you want to learn Java engineering, high performance and distributed, explain the profound things in simple language. Friends of microservices, Spring, MyBatis, and Netty source code analysis can add my Java advanced group: 582505643. In the group, there are Ali Daniel's live broadcast technology, and the video of Java large-scale Internet technology is shared with you for free.

3. The division of responsibilities before and after

In fact, this issue should be considered by every system architecture. Spring Cloud is just a set of frameworks for back-end service governance. The only thing related to the front-end is thymeleaf, which Spring recommends as a template engine. Under normal circumstances, the front-end app or web page calls the back-end service through zuul. If it contains static resources, you can also use nginx to do proxy forwarding.

4. Test

Spring-boot-starter-test supports the testing of methods in each layer of the project, as well as various attributes of the controller layer. Therefore, the general testing steps are as follows. First, developers cover all their own methods, then test all external interfaces in the microservices to ensure the correctness of the microservices, and then conduct integration tests between microservices, and finally deliver the tests.

5. There are many ways to configure

session sharing, such as using tomcat session sharing mechanism, but I recommend using redis cache for session sharing. It can be introduced in batches. In my last company, I was transitioning online in batches. The old and new projects interact through zuul. When introducing in batches, it is best to use Spring Cloud for the new business line first, and transition the old business. Replace all. If it is only request forwarding, the performance of zuul is not necessarily lower than that of nginx, but if static resources are involved, it is recommended to use nginx as a proxy in the front end. In addition, Spring Cloud has a configuration center, which can do all configuration things very flexibly.

6. Deployment Different configurations in

multiple environments, Spring Boot is best at doing this, using different configuration files to configure parameters for different environments, and specifying a configuration file when the service starts, for example: java -jar app.jar --spring.profiles.active=dev is the configuration file to start the test environment; Spring Cloud does not provide a publishing platform, because jenkins is already complete enough, it is recommended to use jenkins to deploy Spring Boot projects, which will save a lot of things; grayscale is temporarily Not supported, you may need to do it yourself. If there are multiple instances, you can update them one by one; it supports hybrid deployment, and it is common to deploy multiple instances on one machine.

7. Development

The html interface you mentioned is the front-end page. Spring Boot can support it, but in fact, Spring Mvc is doing this. Spring Cloud only does service management, and other specific functions are integrated with various frameworks to solve it; excel reports Yes, in fact, except for swing projects, other Java projects can be imagined; Spring Cloud and old projects can be mixed and supported by zuul. Whether to support callback can be achieved through MQ, or emphasize that Spring Cloud is only service governance.

8. Operation and maintenance

Turbine and zipkin can be used for fuse and performance monitoring; dynamic online and offline of a node can be achieved through jenkins; after the provider is offline, there will be other instances of the same to provide services, and Eureka will detect it at intervals Availability of services; configuring different traffic weights for different nodes is not currently supported. The registry must be a high-availability cluster. After the registry dies, all service instances will stop.

In conclusion, whether small and medium-sized enterprises can use Spring Cloud depends entirely on their company's environment. If it is a technically active team, try it boldly. At present, Spring Cloud is the best solution in all microservice governance, and it is also A trend that may be as popular as Spring in the next year or two. Wouldn’t it be better to get in touch and learn early.

Hope that answers your question.

Spring Cloud Architecture

Let's take a look at the main components of Spring Cloud and its access process as a whole





. 1. External or internal non-Spring Cloud projects all access internal services through the API Gateway (Zuul).

2. After the gateway receives the request, Obtain available services from the registry (Eureka)

3. After the load is balanced by Ribbon, it is distributed to the specific instances of the backend

4. Communication between microservices through Feign

5. Hystrix is ​​responsible for handling service timeout fuses

6. Turbine monitors calls between services and fuses related indicators The configuration center is not drawn in the

figure , and the configuration center manages each microservice in different environments. configuration file.

The above is a complete Spring Cloud ecological map.

Guess you like

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