A brief introduction about the HSF framework (1)

HSF introduction


The full name of HSF is high speed frameworkd , which is the RPC framework used internally by Alibaba. It initially competed with Dubbo internally and finally chose HSF for various reasons.
The main reasons are as follows:

The HSF code is less and lighter, and the code size is about 2/3. Dubbo design is more comprehensive and more functional, and more container expansion and replacement of open source components.
HSF's netty + hession transmission performance is higher, and too many internal filters in Dubbo further reduce the performance of RPC.
HSF requires Jboss container binding, which is more intrusive, and needs to customize internal components such as classloader. Dubbo containers are deployed in a general Java environment.
The comparative characteristics of HSF have higher performance, and more internal custom component bindings, so that the performance of RPC is minimized, and the cost of operation and maintenance is minimized, which is important for Ali.
Dubbo features comprehensive functions and easier expansion of open source components, facilitating secondary development. Therefore, it is more suitable for promotion to the open source ecosystem, so Ali decided to re-maintain the open source Dubbo community to increase its influence.
HSF is a point-to-point calling framework, there is no communication bus and service cluster.


HSF main structure


Address registration center (service discovery) The
registration center is the service provider needs to specify some service registration information such as the service name of the service itself. Register the service to the registration center to achieve the function of service discovery.
It is the same as zookeeper in the open source community doing service discovery. The middleware called configServer is currently used for maintenance inside Ali. The node is memory storage and is not persistent.
The configuration server
rpc call may also have some operational requirements, such as timeout and version number isolation from different environments. Routing rules, weights, etc. are controlled by this node, and now the diamond configuration middleware is responsible.
Metadata Persistence Node (Unified Management)
Metadata is to provide convenience for operation and maintenance. It is a non-essential node, which can manage services uniformly and achieve real-time monitoring, operation and maintenance.
HSOPS console
Based on 3 to achieve visual operation and maintenance tools.
Service provider
service consumers
Figure:
Insert picture description here

The main logic
steps are as follows:

The service provider starts the hsf container and reports the service information to the service registration center. The
service provider reports the metadata information.
The service consumer starts the hsf container, pulls the provider information.
Pulls the configuration service information to call.


There are many types of HSF service registration, including the earliest xml, which needs to be bound to the sar environment of alitomcat.
The way to support the lightAPI directly behind the main function start does not require a spring container.
Now the springboot annotation injection method.
Gradually achieved a very similar use method with local calls.

 

demo

Here is the simplest way to register and call the service

/**
* ligthAPI的方式
*/
ServiceFactory serviceFactory = ServiceFactory.getInstance();
XXService xxService = (XXService) serviceFactory
        .consumer("XXService")
        .service("XXService")
        .version("1.0.0.daily").group("HSF")
        .subscribe();

UmsResult<Void> result = xxService.request(request);

to sum up


As a high-performance RPC framework inside Alibaba, HSF has the advantages of light weight, high performance, and low operation and maintenance cost, which provides a good foundation for the application of large-scale clusters.
If you want to complete more complete distributed system service governance and other functions require more peripheral components, these may require secondary development , if you need a more complete ecological dubbo or spring boot is better .
Therefore, choosing different frameworks and components for different scenarios is the last word.

 

reference:

https://blog.csdn.net/micro_hz/article/details/86507317

 

 

 

 


 

Published 162 original articles · won 30 · 90,000 views +

Guess you like

Origin blog.csdn.net/ScorpC/article/details/100567014