The author | Chen (good) Spring Cloud Alibaba project members, director of start.aliyun.com.

This article is based on the author’s “Improving Spring Cloud Alibaba — Framework and Services” shared at the 2020 Cloud Native Microservices Conference. It mainly describes how Spring Cloud Alibaba helps developers to implement microservices in the Cloud native environment. And on the basis of providing SCA development framework, how to cooperate with richer services to help developers to realize microservices on Ali Cloud.

Alibaba cloud native public account background reply 818 can be obtained live back to the address and conference PPT collection.

Spring Cloud Alibaba microservice framework

1. Spring Based Framework has become a de facto standard

Spring Boot has a very high percentage, according to a 2019 Jakarta research report. Anyone familiar with the Java language should be familiar with the Spring framework. The dependency inversion and section-oriented programming features it advocates have become the de facto standard for the Java language, and almost all tripartite frameworks provide support for the Spring framework.

According to a 2019 research report by JetBrings, 61% of users choose Spring Boot over traditional application servers.

Here’s an interesting point. Why “replace the application server”? To review the characteristics of cloud native, we need to be flexible, self-contained, process-independent, etc. If you need to start the application server to deploy the application at this point, this complicates the dependency hierarchy. At the same time, the flexibility and scheduling capabilities of cloud native overlap with traditional application servers. Using Spring Boot directly as an application launch point becomes a more “cloud native” option.

Returning to the microservices & Cloud native scenario, the framework that Spring provides to support development efforts is the Spring Cloud.

2. Spring Cloud is a distributed system construction standard with microservices as the core

Again, let’s look at how Spring defines the Spring Cloud framework:

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state). Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud developers can quickly stand up services and applications that implement those patterns. They will work well in any distributed environment, including the developer’s own laptop, bare metal data centres, and managed platforms such as Cloud Foundry.

Two important features are mentioned here:

  • Common patterns in distributed systems
  • Any distributed environment

“Common patterns in distributed Systems” gives Spring Cloud a clear position as “patterns.” In other words, Spring Cloud is a general abstraction for distributed system development and an implementation of the standard pattern. This definition is so abstract that you don’t know exactly what Spring Cloud contains after reading it. Take a look at the High Light architecture diagram provided by Spring, and you can have a clearer understanding of this mode:

It can be seen that in the middle of this figure are various microservices, namely the realization of our Microservice. The surrounding words are to do various auxiliary information things around this Microservice. Such as distributed tracking, service registration, configuration services, etc., all revolve around the essential supporting functions that the microservices runtime relies on. We can conclude that Spring Cloud is a standard for building distributed systems with microservices at their core.

3. Positioning of Spring Cloud Alibaba

Since The Spring Cloud is a standard, there is no need to implement it against the standard. Here, I would like to introduce the implementation of Spring Cloud Alibaba. First, the following chart is given to help you understand the positioning of Spring Cloud Alibaba:

Here’s a formula for you, and it’s called three plus two.

The 3 refers to the dark part of the figure, which is actually the Spring Cloud standard. There are three layers. The darkest part in the middle is the core of the entire microservice, including “RPC calls” and “service registration and discovery.” The second layer, the one around the core, is the functionality that makes microservices work better, including load balancing, routing, gateways, circuit breakers, and tracking. In the outer layer, it is mainly some common capabilities in distributed cloud environment.

The “2” in “3 plus 2” refers to the outermost circle in the figure above. This part is our definition of Spring Cloud Alibaba, which actually contains two parts:

The upper right section is an implementation of the Spring Cloud standard. For example, we implemented RPC calls through Dubbo, “service registration and discovery”, “distributed configuration” through Nacos, and circuit breakers through Sentinel, to name a few.

The lower left part is the integration of various services of Ali Cloud by our Spring Cloud Alibaba. One question many of you may have is: Why did you add this part? Looking back at Spring Cloud at this point, it is just a framework for microservices. However, in actual production, using a microservice framework alone is not enough to build a complete system. So this part is to use Ali to help developers to complete the integration of cloud products other than micro services.

Many students here may have such a worry: if they use Spring Cloud Alibaba, they will be bound by Alibaba Cloud platform. We are here to make it clear that this is not going to happen. Why do you say that? As mentioned above, the 2 in “3 plus 2” is divided into two parts. The implementation of Spring Cloud is completely independent, and developers can just use this part of the implementation to run on any Cloud platform. Of course, the other part, due to the natural integration of Ali Cloud services, is platform-dependent. This gives developers the freedom to choose whether to use only part of the product or all of it. Of course, we also welcome developers to choose to use the full range of Aliyun services, and we will try our best to ensure consistency and ease of development in using the whole range of products.

4. Comparison of Spring Cloud implementations

As a standard, Spring Cloud certainly has more than one implementation, so what is the difference between each implementation? Let’s take a look at the picture below:

Spring Cloud Alibaba can be found to be the most full-featured of all the implementations. Especially after Netflix stopped updating, Spring Cloud Alibaba continues to update and iterate.

Since Spring Cloud Alibaba officially submitted the code in July, 2018, it has attracted widespread attention. As of today, Spring Cloud Alibaba has more than 15,000 stars, already ahead of all other implementations combined.

Spring Cloud Alibaba has become the most active Spring Cloud implementation, according to the open Source Digitization Report 2020 in Microservices just released by X-Lab This year.

Data source: open Source Digital Report in the Field of Micro services in 2020. The full text of the report can be obtained from the public account background reply keyword “Micro service Report”.

5. Spring Cloud Alibaba ecology

As a cloud vendor, our services are very rich. You can see that in addition to the standard implementation around Spring Cloud, there are various types of services including data, resources, messages, caches, and so on. Under different types of services, there are also many specific products for users to choose from.

This list is typical but not complete. For more information, please refer to the official website of Ali Cloud

6. Number of Spring Cloud Alibaba users

As of today, Spring Cloud Alibaba has received more than 1.5 million stars. Meanwhile, the project dependence on Github, that is, the products dependent on Spring Cloud Alibaba, also exceeds 6000. Most importantly, there are over 1,000 companies using Spring Cloud Alibaba. Of course, it’s not just outside companies that use it, we actually use it ourselves. After the baptism of Double Eleven, in fact, the stability and reliability of the whole set of frames have been confirmed.

From framework to service

1. Provide developer services and a more complete Java development experience

As a framework, Spring Cloud Alibaba provides developers with a convenient programming model, but from the perspective of developers’ complete workflow, is there anything missing? Consider this scenario: as a developer, I should say that I have done the same thing, which is to build a project from scratch, all the way to the process of feature development:

From design to function development, is a relatively long cycle: the first to do abstract design, including outline design, architecture design, etc.; Then some concrete design, there are all kinds of framework building and framework verification and other work.

In the abstract design phase, we need to determine the overall architecture pattern, including microservices, Serverless, event-driven, etc. And the domain boundaries of each application under these architectural patterns.

In the concrete design phase, we determine such things as applying layering and subcontracting rules. There are also many standards to refer to: MVC layered architecture, DDD domain-driven design architecture, and so on. After that, there are concrete business models and interface designs that are beyond the scope of this article.

In the implementation phase, various frameworks need to be introduced and integrated with the application through configuration to complete the creation of the project skeleton.

Finally, the skeleton needs to be up and running to prove its feasibility.

After all the above work is complete, the business logic implementation can begin in earnest.

In the above process, the role of Spring Cloud Alibaba is limited. As a set of framework, for developers to bring the convenience of programming model. To make this process easier for developers, we have two important products: Java Engineering Scaffolding and Sandbox cloud Sandbox.

2. Java Engineering Scaffolding: more suitable for Java developers in Asia Pacific scaffolding

Many developers, like me, have had the experience of starting a new app by taking an old app we’re familiar with and cleaning it of all the business code. Then all configuration names are changed and an empty application template is created. Take this application template and rename it, and it becomes a new application.

Of course, some students may do more, such as maintaining such a blank template there for a long time. Next time you take it out and change the name, it’s a new app.

This may be a relatively safe solution, but the disadvantages are obvious:

  • Versions are old and new features are not available
  • Team knowledge cannot be precipitated
  • Duplication of effort

We solve this problem by providing Java engineering scaffolding. Here is the Java project scaffolding page:

Here, the developer sets basic information about the project, such as the development language, Java version, Spring Boot version, and so on.

In addition to basic information, the platform offers a variety of architectural patterns to choose from. As can be seen in the figure above, the first one is hierarchical architecture, which is a very traditional multi-layer architecture model, including the three-layer architecture and five-layer architecture that we often say. Another architecture option is COLA. COLA is actually a typical DDD architecture. If you want to practice the standard hexagonal DDD architecture in your own team, you can also choose COLA. In the future, we’ll probably do more things like MVC architecture, or event-driven architecture models.

At the bottom is the group price dependencies section, where developers can choose which components to use for their projects. From databases to development tools, messaging, web and more, there are 100+ group prices to choose from, which basically covers all aspects of application development. At the same time, there’s certainly nothing missing from Spring Cloud Alibaba.

We want to use this tool to minimize the number of queries and tedious configuration work developers have to do in the process of creating applications. With a few simple choices on the platform, the skeleton can be generated.

In Java engineering scaffolding, in addition to configuring and downloading projects directly on the WEB platform, we also provide IDE based plug-ins for further user convenience.

Those of you who frequent Spring should be familiar with this interface, which is very similar to the scaffolding provided by Spring. So what’s the difference between our engineering scaffolding and Spring’s official implementation? Is it a mirror image of official features? Take a look at the following comparison:

The differences are mainly in the following aspects:

  • Sample code & typical configuration: There are no examples of code and configuration missing in Spring. In our implementation, this part will be added. Currently, it mainly covers components of Spring Cloud Alibaba, and more components will be covered later.

  • Ali Cloud component support: To ensure the platform neutrality of Spring, components from different manufacturers will not be supported naturally. We provide all open source components of Spring Cloud Alibaba and Service components of Ali Cloud platform. Meanwhile, we will separate these components to avoid mixing with other components and affecting users’ choice.

  • Tool chain: In the official implementation of Spring, for example, the plugin for IDEA is only available in the professional version, that is to say, it is charged. We use Cloud Tookits plug-in to achieve relevant functions, and it is completely free. At the same time, our platform supports 100% official plug-in links.

  • Network environment: Spring official services are deployed abroad, and domestic access is unstable;

 

  • Application architecture: this part is not in the official implementation, which is also the part we will focus on in the future. Application architecture is indispensable in the actual production process.

The localized scaffolding was also recommended by Spring’s official evangelist Josh Long. We will continue the Experience of Spring Initiliazr as long as we can. We will only make incremental features, and this incremental will give users full freedom of choice. That is to say, if we add this item, you can discard it completely. At this time, the overall product experience is exactly the same as the official product experience, which is the principle we will always adhere to in the continued development of the whole product.

Cloud Sandbox: Free and quick verification of cloud products

The second service product is our Sandbox cloud Sandbox. Imagine a scenario where you create a new application today, and after the basic skeleton code has been developed, you need a runtime environment to run it to verify its feasibility or to find out if there are any bugs in it. If I build a complete background service running environment by myself, I can either buy it from a cloud service provider or build it locally. The two options are expensive and laborious.

In addition to verifying the architecture of a new application, there are many other scenarios with similar difficulties. For example, you need to verify the feasibility of a cloud service product, learn how to use the relevant group price, and so on.

So is there a better way? That’s where the Sandbox cloud Sandbox comes in.

This product has three main features: convenience, authenticity and free.

  • Convenient: We have prepared relevant code & development environment & running environment for users. The whole project can be created with just a click of the mouse and deployed in the isolated environment provided by us. There is no need for keyboard in the middle process.

  • Real: it means that the whole product is very close to the actual working scene. From the perspective of developers, the whole r&d process of the project, including code checkout/checkin, development tools, compilation process and deployment process, is the real production process. From the perspective of runtime, all the underlying services use the real services provided by Ali Cloud, without any separate customized services.

  • Free: All services do not charge users, and even all billing activities are not associated with the user’s account.

This product supports a complete distributed scenario. Many other vendors have similar products, but they can only provide cases based on a single container or host, which is different from the actual multi-application distributed environment. And this problem, in our sandbox product is not to worry about. Developers have half an hour to use the application after it is deployed, and there are limitations on traffic and concurrency.

Here’s a look at the product interface:

On the left is the manual and instructions section of the product. This will include a description of the functionality of the current project, the application architecture, and steps on how to deploy and access these applications. Some of the technical points and knowledge used in the project are also presented to the user here. The purpose of this section of documentation is to facilitate the user to learn and understand the current case.

The section on the right is the list of apps. In the microservice scenario, a complete product usually requires multiple applications to form a distributed cluster to work together. This is used to display a list of related applications, and includes entry points for those applications.

The example in the picture is a task manager product with relatively simple functionality. But sparrows have all their organs. The product contains two applications:

  • A server, which contains all the business logic of the task manager, as well as the persistence capability of the lower layer;
  • A WEB client that contains all the front-end page logic and the controller layer that communicates with the front-end.

The two applications use a registry to register and discover services. The end result is a complete task manager product.

Click the “Develop” button to open a Web-IDE to view and modify the code for the application:

The Web-IDE is the same as the IDE developers use every day, with a standard layout of the code tree on the left and the code editor on the right. Even users who are not familiar with the product can get used to it very quickly, and there is no learning process required. To deploy the application, click Deploy under O&M and wait until the deployment is complete. There are many log outputs during deployment, which can be viewed through the Output form:

When the deployment is complete, an access address is returned to the Web-IDE, and the developer can access the application by clicking on it and the address. Below is the actual access. As you can see, two applications, one is the task manager web operation page, the other is the background database management page:

By following these steps, developers can quickly deploy cases. Deploy trials first, then learn and modify the code, and finally deploy validation. This loop allows developers to quickly learn and understand the functionality and technical points of the case.

Finally, take a look at the overall system architecture flow of the sandbox and some key points:

Through the color, it is clear that the resources of the sandbox are divided into two parts. The blue part is actually the user’s proprietary resources, including: private code repository, deployment process, runtime environment, etc. This section is isolated from each other for each user. In particular, you can see in the lower right corner that the entire operating environment is isolated in a separate, private network. If there are multiple applications, they are all linked to the same network. The orange sections are common resources, and there are only two: the case repository and the sandbox backend service.

The second set of concepts are: temporary resources and long-term resources.

Temporary resources, including deployment processes and running processes. These resources will be destroyed after a period of time, so as to ensure that the cost of the whole product is controllable and to avoid the abuse of this product by some users. If you need to continue using the application after the resource is released, you just need to redeploy the application. Long-term resources are resources that will last for a long time. As you can see, the user’s private code repository is a long-term resource. That is, the user’s code is preserved whether the runtime environment survives or not. This part of the code, users can download at any time to their own local, and run in their own environment.

Subsequent planning

The following is the overall planning of Spring Cloud Alibaba and related service products this year:

Later, we will launch a seven-day series of courses based on Sandbox cloud Sandbox. Through this basic knowledge learning + practical operation, we can better master the related technologies of micro-services, especially the use of Spring Cloud Alibaba. In the future, there will be a complete case of e-commerce mall online in sandbox, including the second kill case with high concurrency scenarios. Finally, Spring Cloud Alibaba itself will continue to build and integrate at least 20 Cloud products commonly used in Alibaba Cloud. Further enhance the convenience of development.

If you are interested in further understanding of this product, or have better opinions or suggestions, welcome to join dingdinggroup (Dingdingsearch: 34930571) to communicate and make fun of it.

Alibaba cloud native public account background reply 818 can be obtained live back to the address and conference PPT collection.

“Alibaba Cloud originator focuses on micro-service, Serverless, container, Service Mesh and other technical fields, focuses on the trend of cloud native popular technology, large-scale implementation of cloud native practice, and becomes the public account that most understands cloud native developers.”