Ant middleware introduction: SOFA

All middleware is designed to solve a problem in a specific domain

SOFA solves the problem of distributed service and component management and cumbersome calls

Sofa brain map

image.png

1. What is Sofa?

SOFA is derived from Service Oriented Fabric Architecture, which is a service-oriented architecture.
With the open source of SOFA, the new interpretation of SOFA: Scalable Open Financial Architecture

SOFA is a financial-level distributed middleware independently developed by Ant Financial. It includes various components required to build a financial-level cloud-native architecture, including microservice R&D framework, RPC framework, service registration center, distributed timing tasks, current limiting/fusing framework, dynamic configuration push, distributed link tracking, Metrics monitoring measurement, distributed high-availability message queue, distributed transaction framework, distributed database proxy layer and other components.

2. Why use Sofa


Differences between Sofa and Spring cloud
In SOFA, the entire system is split into modules (bundles), while in Spring Cloud, the system is split into multiple microservices (MicroServices). In fact, the meaning is similar. Each module (service) performs its own duties and is called through JVM/RPC. SOFA can call the interface between services through JVM/RPC, while Spring Cloud can only call through RPC/HTTP

Sofa Advantages
SOFA is a technical solution accumulated by Ant Financial for a long time. Before the emergence of SpringCloud, SOFA was able to run stably in the financial cloud environment. And SOFA is a set of solutions developed by Ant Financial. It naturally integrates functions such as RPC and service routing. It can be seamlessly integrated with other middleware in Ant Financial (such as zdal, drm, msgbroker, etc.). .

For a more detailed comparison, please refer to: Comparison between Spring Cloud and SOFA

3. Advantages of Sofa

Modular, with clear module boundaries and easy maintenance.
Servitization, service registration and dependency are very convenient.
Easy to extend, well defined extension points and extensions.

4.Sofa function

Sofa
service release and reference
Through the release and reference of SOFA JVM service, the communication problem of isolating SOFA modules is solved. SOFA provides three ways for developers to publish JVM service and reference, namely: XML method, Annotation method and programming API method.

Spring configuration based on Velocity
SOFA's Spring configuration file is based on Velocity. According to different configuration files of users, different beans will be initialized to improve flexibility.

Life cycle management
The SOFA framework includes complete life cycle management, and applications can monitor the life cycle events of SOFA applications or SOFA components.

Log4j2 supports
SOFA framework to support Log4j2 to realize asynchronous printing of logs. At the same time, the SOFA framework implements the function of dynamically adjusting the log level based on DRM.

SOFA extension point
The modules of the SOFA framework are isolated from each other, and the SOFA extension point allows a module to customize the components defined in the modules it depends on.

Health Check
The SOFA framework provides a set of extensible health check mechanisms that can help applications determine whether they are healthy after startup and whether they can provide external services.

Sofa RPC
remote call
An efficient and transparent remote service call based on TCP and its own binary protocol, supports more complex objects, and provides richer calling methods (sync, oneway, callback, future, etc.).

Service discovery
The service provider automatically registers to the service registry; the service consumer subscribes to the address of the service provider from the registry; supports the automatic discovery of provider address changes, providing good scalability for the service.

Cluster fault tolerance
The service caller performs automatic fault tolerance when some service providers have problems.

Service routing and load balancing

If there are multiple available service providers, the service caller selects one of them to call locally according to the server routing and load balancing algorithm. It can replace F5 and other hardware load balancers in the intranet, which not only solves the single point problem of the system, but also greatly reduces the cost of the enterprise.

A good extension interface
can implement functions based on various extensions.
5.Sofa layered
image.png

image.png

The Spring Context between each module in the SOFA application is completely isolated. When splitting is required, the modules can be split directly, and the calling method can be changed from local service to remote service. Local services can be understood as registered in the local registration center, and the services are called through the JVM. After the split, the remote services are registered in the remote registration center, and the services are called through RPC.

6. Health check

Before the health check, first call the deployCompletion method of each component, and the ApplicationStartupCallback method of the application.
Health check content
Check whether the Spring context is started successfully Check
the user-defined check items
Check whether all components with traffic outlets (SOFA Reference, message sending end) are healthy; if they fail, continue to check 20 times every 500ms

image.png

7.Sofa RPC

image.png

8. Sofa source code learning

Sofa source code learning moved to: https://www.jianshu.com/p/ab3acb2bb518
Other
service publishing: In fact, it provides mutual access permissions for different isolated spring context modules and components

Author: Want Want Big Senbei
Reprint link: https://www.jianshu.com/p/e3dca8d5e9ee

Guess you like

Origin blog.csdn.net/qq_39463175/article/details/130517345