High-speed Service Framework (HSF) is a distributed remote procedure call (RPC) service framework that is widely used in Alibaba Group.
Overview
HSF acts as an intermediary between different business systems, which helps decouple these systems and allows them to become less interdependent. HSF unifies the service publishing and call methods for distributed applications. HSF manages the complex technical operations involved in distributed architectures, such as remote communication, serialization, performance loss, and implementation of synchronous and asynchronous calls. You can use HSF to quickly develop distributed applications and provide or use public function modules.
HSF architecture
HSF is an RPC framework that works entirely on the client side, and does not process requests through a central cluster. All HSF services are called between service consumers and service providers in point-to-point mode. HSF must depend on the following external systems to implement a complete distributed service system.
- Service provider
A service provider uses port 12200 to receive requests, provide services, and publish the address information to an address registry.
- Service consumer
A service consumer subscribes to services by using the address registry and initiates calls based on the address information of the subscribed services. The address registry is not involved in calls.
- EDAS address registry
HSF can implement service discovery only through the address registry. Otherwise, HSF can implement only point-to-point calls.
The service provider cannot expose its service information, so the service consumer cannot obtain the service that it wants to call. In this case, the address registry serves as an intermediary that enables service registration and discovery.
- EDAS persistent configuration center
The persistent configuration center is used to store governance rules for HSF services. Upon startup, the HSF consumer subscribes to required rules, such as routing rules, grouping rules, and weighting rules, from the persistent configuration center. In this way, the consumer can determine the address selection logic during the call.
- EDAS metadata storage center
Metadata includes the information related to HSF services, such as methods and parameter structures. Metadata does not affect the calls of HSF services. Therefore, the metadata storage center is optional. To facilitate service O&M, when HSF starts up, the HSF consumer reports metadata to the metadata storage center.
- EDAS console
The EDAS console connects the registry, persistent configuration center, and metadata storage center. The console provides service O&M features, such as service query and management of service governance rules. This improves R&D efficiency and facilitates O&M for HSF services.
Features
The distributed RPC framework HSF supports the following service call methods:
- Synchronous calls
By default, an HSF consumer uses synchronous calls to consume services, and the consumer must wait for the returned results of each call.
- Asynchronous calls
HSF supports asynchronous calls so that the HSF consumer does not need to wait for the returned results of all service calls. Asynchronous calls can be made by using the Future and Callback methods.
- Future calls
The HSF consumer calls HSFResponseFuture.getResponse (int timeout) to obtain the returned results of calls.
- Callback calls
The calls are made by using the internal Callback mechanism provided by HSF. After an HSF service is consumed and the results are returned, HSF calls the
HSFResponseCallback
operation. The consumer then obtains the call results from callback notifications.
- Future calls
- Generic calls
Typically, an HSF consumer calls a service and obtains the returned values by using the APIs in the SDK from the service provider. However, generic calls allow HSF consumers to bypass the SDK and directly call services to obtain data. Implementing generic calls for platform-based services allows you to rely less on SDKs and build a lightweight system.
- Trace filter extension
HSF has a built-in call filter and can identify and integrate your call filter extension points into HSF call traces. This allows the extensions to process HSF requests.
Application development methods
HSF allows you to develop applications in Ali-Tomcat and Pandora Boot.
- Ali-Tomcat: This method depends on Ali-Tomcat and Pandora, and provides complete HSF features such as service registration and discovery, implicit parameter passing, asynchronous calls, generic calls, and trace filter extension. Applications must be deployed in the form of WAR packages.
- Pandora Boot: This method depends on Pandora and provides some HSF features, such as service registration, service discovery, and asynchronous calls. Applications must be compiled into executable JAR packages for deployment.