CN113114765A - Interface calling system based on reverse proxy - Google Patents
Interface calling system based on reverse proxy Download PDFInfo
- Publication number
- CN113114765A CN113114765A CN202110392902.4A CN202110392902A CN113114765A CN 113114765 A CN113114765 A CN 113114765A CN 202110392902 A CN202110392902 A CN 202110392902A CN 113114765 A CN113114765 A CN 113114765A
- Authority
- CN
- China
- Prior art keywords
- function
- api
- node
- interface
- list
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000006870 function Effects 0.000 claims abstract description 99
- 238000011161 development Methods 0.000 claims abstract description 28
- 238000013507 mapping Methods 0.000 claims description 16
- 238000013461 design Methods 0.000 abstract description 6
- 230000005540 biological transmission Effects 0.000 abstract description 5
- 238000005516 engineering process Methods 0.000 abstract description 2
- 238000000034 method Methods 0.000 description 13
- 230000008569 process Effects 0.000 description 7
- 230000004044 response Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012544 monitoring process Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000012216 screening Methods 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000013499 data model Methods 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000001105 regulatory effect Effects 0.000 description 1
- 238000012827 research and development Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
- H04L67/63—Routing a service request depending on the request content or context
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/66—Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
- H04L67/1004—Server selection for load balancing
- H04L67/1023—Server selection for load balancing based on a hash applied to IP addresses or costs
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses an interface calling system based on a reverse proxy, which is applied to the field of computers and aims at solving the problem that the existing interface calling technology cannot adapt to a large-scale software system; then, transparent transmission is carried out through JSON when the interface is called, wherein the interface is attached with version information, and the same interface allows a plurality of versions, so that the version interchange function in iterative development is realized; the interface design comprises a development group concept, a plurality of calling parties are allowed to be classified into one group, data and scheduling between the groups are not interfered with each other, and the problem of interruption point interference in multi-person collaborative development is avoided; because restful is adopted as a transmission protocol, the interface is independent of languages, and cross-language collaborative development can be realized.
Description
Technical Field
The invention belongs to the field of computers, and particularly relates to an interface calling technology.
Background
Due to the fact that the large-scale software system is often built depending on multiple iterations due to service complexity, the performance bottleneck of an interface, the disordered interface version, repeated development and other problems are easily caused, and therefore progress is delayed, and the research and development work cannot be completed with guaranteed quality. Therefore, an interface calling model based on a reverse proxy is designed, and load balancing is achieved in a distributed deployment mode; and realizing version management through an interface registration mode.
Disclosure of Invention
In order to solve the technical problem, the invention provides an interface calling system based on a reverse proxy.
The technical scheme adopted by the invention is as follows: a reverse proxy-based interface invocation system, comprising: requesting a client, a gateway service and an execution node; the request client is used for sending a request calling function, the gateway service determines a selection execution node according to the calling function, the selected execution node returns an execution result to the gateway service, and the gateway service outputs the received execution result to the request client;
the gateway service includes: the system comprises an API registration service unit, an API cache pool and an API caller; the API registration service unit monitors a function registration port in a TCPServer mode and receives function registration from an execution node;
the API cache pool is used for storing execution node information and a called function;
the API caller is used for acquiring a corresponding execution node when the function search is executed;
the execution node includes: API collector, node service unit, executor;
the API collector is used for extracting function annotation information to form a function list and registering the function list to the gateway service;
the node service unit is used as a TCPServer form to monitor a called port, and is connected with gateway service in a TcpClient mode to perform API function registration;
the executor is used for executing specified function logic.
The gateway service adopts SpringBoot as a bottom container and provides a uniform RESTFUL calling interface.
The data type of the call function for the call reference is JSON.
The requesting participation comprises: the requested IP address, the function name, the function version number, and the parameter information received by the function.
The API cache pool is used for caching an API list in a gateway service in a memory mode, is initialized and created when the gateway service is started, and stores information such as the name of an execution function and an IP port of a pointed execution node in a list mode. And the execution node submits development group information of the execution node when registering the API, forms a function list on the API registration service unit and adds the function list to the API cache pool.
The interface function is registered in a development group of the API cache pool.
The development group is designed to isolate simultaneous debugging by multiple developers to prevent breakpoints from interfering with each other. And grouping the API lists through the Group values, and screening the API functions by using the Group fields when calling. And submitting the development Group information of the execution node when registering the API, and defining the function mapping relation and the node mapping relation of the API function information in a HashMap mode and storing the function mapping relation and the node mapping relation in a corresponding development Group in a list form.
The function mapping relationship is specifically as follows: the function list forms a correspondence for values with the IP port as a key.
The node mapping relationship is specifically as follows: and forming correspondence by taking the function name as a key and the calling node as a value.
The process of the API caller acquiring the corresponding execution node is as follows: the method comprises the steps of firstly obtaining an API list by a development group of requested data, then obtaining an execution node list through a function name, and finally obtaining a corresponding execution node through a configured load balancing algorithm.
The invention has the beneficial effects that: the system of the invention comprises the following advantages:
1. the system is designed to be composed of a gateway and execution nodes, wherein the gateway realizes a distributed architecture by requesting the gateway to call the nodes in a reverse mode based on a reverse proxy mode, and forms load balance, so that execution pressure is dispersed;
2. transparent transmission is carried out through JSON when the interface is called, wherein the interface is attached with version information, and the same interface allows a plurality of versions, so that the version interchange function in iterative development is realized;
3. the interface design comprises a development group concept, a plurality of calling parties are allowed to be classified into one group, data and scheduling between the groups are not interfered with each other, and the problem of interruption point interference in multi-person collaborative development is avoided; because restful is adopted as a transmission protocol, the interface is independent of languages, and cross-language collaborative development can be realized.
Drawings
FIG. 1 is a system composition of the present invention;
FIG. 2 is a design composition of a gateway service and enforcement node of the present invention;
FIG. 3 is a diagram illustrating the components of the function mapping relationship and the node mapping relationship of the present invention;
FIG. 4 is a logical block diagram of an API caller of the present invention;
FIG. 5 is an API scheduling flow of the present invention;
FIG. 6 is a flow chart of a calling API of the present invention.
Detailed Description
In order to facilitate the understanding of the technical contents of the present invention by those skilled in the art, the present invention will be further explained with reference to the accompanying drawings.
The gateway and the execution node are separated by utilizing a TCP communication mode, and a plurality of nodes are allowed to process the same function, so that the pressure of the server is reduced, development languages are not related, and the iterative hybrid development requirement of the system is met.
In the design, the gateway service is used as a uniform gateway, requests of client application programs are dispatched to a back-end execution node for processing according to a certain rule, and data are responded to the client after a processing result is received, so that a reverse proxy mechanism is formed. At this time, the source of the request (the requesting client) is clear, but it is not clear which server the request is specifically processed by, the client is unaware of the existence of the proxy, the reverse proxy is transparent to the outside, and the visitor does not know that the visitor accesses the proxy. As the client does not need any configuration to access.
As shown in fig. 1, the system of the present invention comprises: the gateway service and the execution node carry out data transmission in a TCP mode, and the gateway service provides a calling function in a RESTFUL form.
As shown in fig. 2, the gateway service design is composed of an API registration service, an API buffer pool, and an API caller, and uses SpringBoot as a bottom container to provide a unified RESTFUL call interface.
The gateway service monitors a registration port after being started, and an execution node registers a provided function to a gateway in a TCP mode after being started to form an API list; other applications request the registered API function through the restul interface.
Spring boot frame: the gateway service provides a RESTFUL unified request interface, so that SpringBoot is adopted as a bottom-layer container, a standard POST request function is adopted as a unique transparent interface, and the prototype is as follows:
@ResponseBody
@RequestMapping(path="/getResult",method=RequestMethod.POST)
public ResultModel getResult(
@RequestBody Argument invokeArgs,
HttpServletRequest request)
the invokeArgs is used as a request entry, the data type of the invokeArgs is JSON, the invokeArgs comprises an IP address, a function name, a function version number of the request and parameters or other parameter information received by the function, and the invokeArgs is defined as follows:
the return value (response) data model includes: the method comprises the following steps of requesting a function name, a function version number, a function access return code and a function response return value, wherein in order to better adapt to various parameter transfers, the return value type is wrapped in Object, and the data type of the return value type is defined according to datatype, and the method comprises the following steps: string, int, double, pool, JsonAlrray, JsonObject, etc., which are defined as follows
API registration service: monitoring a function registration port in a TCPServer mode, receiving function registration from an execution node, and storing the execution node information and the called function to an API cache pool.
API cache pool: in order to quickly find calling functions and nodes, all registered functions are stored in a cache pool. In order to ensure the accuracy of multi-user collaborative development and breakpoint debugging, a development group is introduced into the design. And the execution node submits development group information of the execution node when registering the API, forms a development list on the API registration service and forms an API cache pool. The functional prototype of the development group is as follows:
the interface function is registered in a development group of the API cache pool, and as shown in fig. 3, the development group defines a function mapping relationship in a HashMap manner, and the node mapping relationship is formed. The function mapping relationship is formed by taking an IP PORT (IP: PORT in FIG. 3) as a key and taking a function list (Func 1, Func2, … and Funcn in FIG. 3) as a value to correspond to each other; the Node mapping is mapped by using function name (Func in fig. 3) as key and calling Node (Node 1, Node2, …, Node n in fig. 3) as value.
An API caller: when the function search is executed, the corresponding development group is obtained by the group parameter carried by the requested Url address, the API list of the development group is obtained, the execution node list is obtained in the function mapping relation through the method parameter, the corresponding node is obtained through the configured load balancing algorithm, the function calculation is executed, the data is returned, and the logic process is shown in FIG. 4.
The execution node consists of an API collector, a node service and an executor.
An API collector: a set of function annotations is defined at the execution node and used for marking function information. When a developer writes an interface function, the developer needs to annotate a class and the interface function through annotations, and the annotating process is the same as that of the SpringBoot interface function.
When the execution node is started, the API collector conducts traversal reflection on the loaded class, class instances are obtained through annotation, and therefore function annotation information is extracted, a function list is formed, and the function list is registered to the gateway service. The function list exists in a JSON form and comprises information such as the full name, description, parameters, return values and the like of the function.
And (3) node service: in the execution node, the called port is monitored as a TCPServer form, and the gateway service is connected in a TcpClient mode for carrying out API function registration.
An actuator: when the node service receives a request from the gateway service, the call executor executes the specified function logic. The actuator analyzes the received called function description, performs function reflection according to the complete path name to form a function instance, calls a local function in a reflection mode, and transmits a return value to the gateway service.
The working principle of the invention is as follows:
as shown in FIG. 5, the whole working process of the system operation is divided into a registration phase and a calling phase. The registration stage is mainly the starting and initialization of each service, and the process of registering the local function to the gateway service by the execution node is completed; the calling stage is a process of receiving a request through the gateway service, scheduling the request to an execution node, realizing function operation and responding to a calling party.
The system is initially started, the gateway service monitors the gateway port, and waits for node registration and interface calling.
When the execution node is started, firstly monitoring a regulated port according to configuration, then forming an API list by acquiring a local API interface function, and registering the node information to a gateway service, wherein the node information comprises: node IP, called port number and API function list; after receiving the registration information, the gateway service caches the API list in a key value pair form and carries out server caching on an interface function-execution node list, and a mapping relation of the interface function corresponding to a plurality of execution nodes is formed.
When the application program calls the API, as shown in fig. 6, a function is requested to the gateway service, the gateway service performs screening according to the execution node list corresponding to the call function, determines to select an execution node through a load balancing algorithm (mainly including polling, random, task optimization), the gateway service actively connects to a called port of the execution node through a TCP method, and transfers the call information as a parameter to the execution node. The execution node forms a class instance in a reflection form by calling an interface full path (packet name + class name + function name) in the information, executes the segment function, and outputs an execution result to the gateway service through TCP. After receiving the data, the gateway service forms a response stream with the data in a restful interface mode and outputs the response stream to the calling program, and finally the calling program displays the result through the interface.
It will be appreciated by those of ordinary skill in the art that the embodiments described herein are intended to assist the reader in understanding the principles of the invention and are to be construed as being without limitation to such specifically recited embodiments and examples. Various modifications and alterations to this invention will become apparent to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.
Claims (7)
1. A reverse proxy-based interface invocation system, comprising: requesting a client, a gateway service and an execution node; the request client is used for sending a request calling function, the gateway service determines a selection execution node according to the calling function, the selected execution node returns an execution result to the gateway service, and the gateway service outputs the received execution result to the request client;
the gateway service includes: the system comprises an API registration service unit, an API cache pool and an API caller; the API registration service unit monitors a function registration port in a TCPServer mode and receives function registration from an execution node;
the API cache pool is used for storing execution node information and a called function;
the API caller is used for acquiring a corresponding execution node when the function search is executed;
the execution node includes: API collector, node service unit, executor;
the API collector is used for extracting function annotation information to form a function list and registering the function list to the gateway service;
the node service unit is used as a TCPServer form to monitor a called port, and is connected with gateway service in a TcpClient mode to perform API function registration;
the executor is used for executing specified function logic.
2. The system as claimed in claim 1, wherein the gateway service uses SpringBoot as the bottom container to provide a unified RESTFUL invocation interface.
3. The reverse-proxy-based interface call system as claimed in claim 2, wherein the data type of the call function for requesting entry is JSON.
4. The reverse-proxy-based interface invocation system according to claim 3, wherein said requesting participation includes: the requested IP address, the function name, the function version number, and the parameter information received by the function.
5. The system according to claim 4, wherein the executing node submits the development Group information to which the executing node belongs when registering the API, forms an API function list on the API registration service unit, and adds the API function list to the API cache pool, and the API cache pool caches the API list in the gateway service in a memory manner.
6. The reverse-proxy-based interface invocation system according to claim 5, wherein the API list is grouped by forming key-value pairs with the Group value at registration as a key, and wherein the API list is filtered with the Group value passed as a key at invocation.
7. The reverse-proxy-based interface calling system as claimed in claim 6, wherein the API function information defines its function mapping relationship and node mapping relationship in a HashMap manner, and is stored in the corresponding development Group information in the form of API list.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110392902.4A CN113114765A (en) | 2021-04-13 | 2021-04-13 | Interface calling system based on reverse proxy |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110392902.4A CN113114765A (en) | 2021-04-13 | 2021-04-13 | Interface calling system based on reverse proxy |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113114765A true CN113114765A (en) | 2021-07-13 |
Family
ID=76716167
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110392902.4A Pending CN113114765A (en) | 2021-04-13 | 2021-04-13 | Interface calling system based on reverse proxy |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113114765A (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9936005B1 (en) * | 2017-07-28 | 2018-04-03 | Kong Inc. | Systems and methods for distributed API gateways |
CN108093086A (en) * | 2018-01-22 | 2018-05-29 | 微梦创科网络科技(中国)有限公司 | The data transmission method and system of a kind of gateway |
US20180278705A1 (en) * | 2017-03-24 | 2018-09-27 | Accenture Global Solutions Limited | Reactive api gateway |
CN109120717A (en) * | 2018-09-26 | 2019-01-01 | 中国平安人寿保险股份有限公司 | Reverse proxy method, apparatus and storage medium, distributed system |
CN109194604A (en) * | 2018-06-05 | 2019-01-11 | 平安科技(深圳)有限公司 | Interface automatic method, system, computer equipment and storage medium |
CN109241767A (en) * | 2018-08-02 | 2019-01-18 | 浪潮软件集团有限公司 | Security control system and method for unstructured data resources |
CN109510846A (en) * | 2017-09-14 | 2019-03-22 | 北京金山云网络技术有限公司 | API Calls system, method, apparatus, electronic equipment and storage medium |
CN109981757A (en) * | 2019-03-13 | 2019-07-05 | 青岛特锐德电气股份有限公司 | A kind of API gateway load-balancing algorithm towards small-scale micro services framework |
CN110837408A (en) * | 2019-09-16 | 2020-02-25 | 中国科学院软件研究所 | High-performance server-free computing method and system based on resource cache |
-
2021
- 2021-04-13 CN CN202110392902.4A patent/CN113114765A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180278705A1 (en) * | 2017-03-24 | 2018-09-27 | Accenture Global Solutions Limited | Reactive api gateway |
US9936005B1 (en) * | 2017-07-28 | 2018-04-03 | Kong Inc. | Systems and methods for distributed API gateways |
CN109510846A (en) * | 2017-09-14 | 2019-03-22 | 北京金山云网络技术有限公司 | API Calls system, method, apparatus, electronic equipment and storage medium |
CN108093086A (en) * | 2018-01-22 | 2018-05-29 | 微梦创科网络科技(中国)有限公司 | The data transmission method and system of a kind of gateway |
CN109194604A (en) * | 2018-06-05 | 2019-01-11 | 平安科技(深圳)有限公司 | Interface automatic method, system, computer equipment and storage medium |
CN109241767A (en) * | 2018-08-02 | 2019-01-18 | 浪潮软件集团有限公司 | Security control system and method for unstructured data resources |
CN109120717A (en) * | 2018-09-26 | 2019-01-01 | 中国平安人寿保险股份有限公司 | Reverse proxy method, apparatus and storage medium, distributed system |
CN109981757A (en) * | 2019-03-13 | 2019-07-05 | 青岛特锐德电气股份有限公司 | A kind of API gateway load-balancing algorithm towards small-scale micro services framework |
CN110837408A (en) * | 2019-09-16 | 2020-02-25 | 中国科学院软件研究所 | High-performance server-free computing method and system based on resource cache |
Non-Patent Citations (5)
Title |
---|
佚名: "Spring Cloud入门(二) Zuul服务网关、Ribbon负载均衡、Feign声明式接口调用", 《NICETHEMES.CN/NEWS/TXTLIST_I45985V.HTML》 * |
康志辉: "基于反向代理的资源服务器重定向技术研究", 《西安文理学院学报(自然科学版)》 * |
温馨等: "基于OpenResty平台的API网关系统的设计与实现", 《信息化研究》 * |
王文俊等: "Web Services构架下的空间应用集成框架", 《计算机辅助设计与图形学学报》 * |
邹万芳: "嵌入式仪器网管代理服务系统的设计与实现", 《无线互联科技》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10447772B2 (en) | Managed function execution for processing data streams in real time | |
US11775343B1 (en) | Duty cycle estimation for job assignment | |
Jun et al. | Agent-based resource discovery | |
Baresi et al. | Microservices: The evolution and extinction of web services? | |
US7607128B2 (en) | Method and system for enabling a server application to be executed in the same virtual machine as a client application using direct object oriented programming method calls | |
CN105765578B (en) | Parallel access of data in a distributed file system | |
US20050268309A1 (en) | Transparent and sub-classable proxies | |
CA2807759C (en) | Application monitoring | |
US7849472B1 (en) | System for instrumenting resources utilizing WS-management resource MBean wrappers for JAXB beans | |
CN104270443B (en) | A kind of cloud computing system and method for being capable of dynamic analysis Web applications | |
WO2017166166A1 (en) | System and method for providing runtime tracing for web-based client accessing transactional middleware platform using extension interface | |
CN116204239A (en) | Service processing method, device and computer readable storage medium | |
Duan et al. | NetStar: A future/promise framework for asynchronous network functions | |
US20080065679A1 (en) | Method for rules-based drag and drop processing in a network environment | |
CN113114765A (en) | Interface calling system based on reverse proxy | |
US20160105347A1 (en) | Method of tracing a transaction in a network | |
Krishnamurthy et al. | Programming frameworks for Internet of Things | |
Snyder et al. | Using logical operators as an extended coordination mechanism in Linda | |
Fabra et al. | RLinda: a Petri net based implementation of the Linda coordination paradigm for Web services interactions | |
Finocchio et al. | MTCL: a multi-transport communication library | |
Lutz | Enhancing the performance of twitter storm with in-network processing | |
Goronjic et al. | Miso: A crdt-based middleware for stateful objects in the serverless edge-cloud continuum | |
Dias et al. | BrowserCloud. js-A federated community cloud served by a P2P overlay network on top of the web platform | |
US11468101B2 (en) | Context-rich key framework implementations for global concept management | |
Padole | Big Data Analysis on Heterogeneous Distributed Systems using Remote Method Invocation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210713 |
|
RJ01 | Rejection of invention patent application after publication |