Key Takeaways Cloud native applications should exploit full advantages of cloud, rather than just migrating into cloud Microservice go with cloud native hand in hand, by running on cloud computing environment Centralized config, services discovery, asynchronous message driven and distributed tracing are microservice infrastructure Spring Cloud provides common microservice patterns and abstraction without locking on specific implementation Spring Cloud Azure follows abstractions provided by Spring Cloud, and provides seamless integration with Azure services

For the past decade, Spring has beenfamous for its dependency injection feature which helps Java developers build loosely coupled system. Put simply, users just need to focus on abstraction provided by interface, then instance of concrete implementation will be ready for use. As cloud become increasingly popular in recent years, how to exploit the auto-scaling and auto-provisioning features provided by cloud environment and loose coupling with specific cloud vendors becomes an interesting challenge. That's where cloud native come into play. Let's move forward to see whatcloud native and microservice are first.

Cloud native and microservice What exactly is "Cloud Native"?

Even I have seen this term many times, and it's still not an easy question. Cloud native is a lot more than just signing up with a cloud provider and using it to run your existing applications. It pushes you to rethink the design, implementation, deployment, and operation of your application. Let's look at two popular definitions first:

Pivotal, the software company that offers the popular Spring framework and a cloud platform, describes cloud native as:

Cloud native is an approach to building and running applications that fully exploit the advantages of the cloud computing model.

The Cloud Native Computing Foundation, an organization that aims to create and drive the adoption of the cloud-native programming paradigm, defines cloud-native as:

Cloud native technologies empower organizations to build and run scalable applications in modern, dynamic environments such as public, private, and hybrid clouds. Containers, service meshes, microservices, immutable infrastructure, and declarative APIs exemplify this approach.

To summarize, cloud native application should utilize the advantages of the cloud computing model. And microsevice is one way to implement it. Maybe the following explanation will make this more clear:

A cloud native application is specifically designed for a cloud computing environment as opposed to simply being migrated to the cloud. What exactly is "Microservice"?

Let's check Martin Fowler's definition of microservice first:

Microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.

But I love another simple one:

Microservices are small, focused and autonomous services that work together.

Small and focused means Single Responsibility. One service just needs to do one thing well. Autonomous means fault tolerance and each service evolves and deploys independently from each other.

The concept of microservices is nothing new. But it hasn't been so popular due to hard implementation in traditional on-premise organizations. Now cloud-based microservicestaking full advantageof scalability, reliability and low maintenance costs provided by cloud have become more popular.

Key benefits are outlined below:

Resilience . One component's failure shouldn't take down the whole system. This is usually achieved by defining a clear service boundary. Scaling . You don't need to scale everything together when only one part is constrained in performance. Ease of deployment . Making a change to a single service can speed the release cycle and smooth the troubleshooting process. Composablility . Since each service focuses on one thing, it's easy to reuse them like a unix pipeline. Optimizing for replaceablity . One small individual service is easier to replacewith a better implementation or technology. Spring Cloud

In order to implement microservice architecture easily, the industry has identified some common patterns to help this. Some well-known patterns are centralized configuration management, service discover, asynchronous message-driven and distributed tracing. Spring Cloud provides these patterns as usable building blocks and helps us follow the cloud native best practices. Besides this, Spring Cloud's unique value could be represented in several aspects:

Define a common abstraction for frequently used patterns . This is another beautiful application of Spring's decoupling philosophy. Each pattern is not tightly coupled with concrete implementation. Take config server as example;you have the freedom to change backend storage without affecting other services. Discovery and Stream also followed this. Modular component . On first impression, many people think Spring Cloud as a fully-packaged solution. Actually, it's not an all-or-nothing solution. You can only choose one module, then use it as one microservice;other services have the freedom to use any other framework. It's like Lego-brick;you can pick only the pieces you like, and the only thing you need to make sure of is that the pieces becompatible with others.

Now let's look at how spring cloud module fits into microservice pattern.

Decoupling in Cloud Era: Building Cloud Native Microservices with Spring Cloud A ...
Centralized config management via Spring Cloud Config

To meet the requirement of Store config in environment and micro-service architecture, we need to put all services' config in one centralized place. To fulfill this, the following features are needed:

Support multiple environments such as dev, test and prod . Then we can have one package built for all environments. Transparent config fetching. These centralized config should be fetched automatically without any user coding. Automatic property refresh when property changes . The service should be notified by such change and reload new property. Maintain change history and easily revert to older version. This is a really useful feature to revert mistaken changes in production environment.

Spring Cloud Config supports all these features by using onesimple annotation @EnableConfigServer in config service and includestarter in other services to enable client. For more details, please refer to the Spring Cloud Config doc .

Service Discovery via Spring Cloud Discovery Service discovery plays an important role in most distributed systems and service oriented architectures. The problem seems simple at first: how do clients know the IP and port for a service that could exist on multiple hosts? Things get mo

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

本文标题:Decoupling in Cloud Era: Building Cloud Native Microservices with Spring Cloud A ...

技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(56)