WO2018121625A1 - 业务访问请求的处理方法和相关设备 - Google Patents

业务访问请求的处理方法和相关设备 Download PDF

Info

Publication number
WO2018121625A1
WO2018121625A1 PCT/CN2017/119108 CN2017119108W WO2018121625A1 WO 2018121625 A1 WO2018121625 A1 WO 2018121625A1 CN 2017119108 W CN2017119108 W CN 2017119108W WO 2018121625 A1 WO2018121625 A1 WO 2018121625A1
Authority
WO
WIPO (PCT)
Prior art keywords
container
destination
service
application
access request
Prior art date
Application number
PCT/CN2017/119108
Other languages
English (en)
French (fr)
Inventor
刘洪宇
Original Assignee
华为技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2018121625A1 publication Critical patent/WO2018121625A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1012Server selection for load balancing based on compliance of requirements or conditions with available server resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Definitions

  • the present invention relates to the field of information technology, and in particular, to a method and a related device for processing a service access request.
  • containers have many advantages over traditional virtualization, one of which is lightweight and enables faster delivery and deployment.
  • the startup time of the container is usually in the order of seconds, so that the time for the business to go online can be greatly saved.
  • the container runs on the container engine of the host, and provides an access port.
  • the host forwards the service access request to the container, and the application service in the container processes the service access request.
  • the container can be started in seconds
  • the application service in the container cannot be started in seconds.
  • the application service needs to read related configuration files, load dependent files, and connect to the database during the startup process, so the application service startup time is longer than the container.
  • the container when the container is not started, and the host receives a service access request for the application service in the container, the container is started, and the service access request is directly forwarded to the container, because the startup speed of the container is fast.
  • the container When a business access request is sent to the container, the container has been started, but since the application service in the container has a long startup time, when the container receives the service access request, the application service that processes the service access request may still be in During the loading process, the startup is not completed, and the service access request cannot be processed, and the client's access to the application service fails.
  • An embodiment of the present invention provides a method for processing a service access request and a related device, so that the container receives the service access request only after the application service is started, and prevents the container from receiving the service access request before the application service is started. Access failed.
  • the application provides a host, including a host operating system, a request processing device, an application state library, and a container.
  • the host operating system includes a container engine, and the container runs on the container engine, and the container includes an application service and an application service monitoring module.
  • the application state library may record the state of the application service running in the container, request the processing device to receive the service access request of the client, and the destination port of the service access request is the host port of the destination application service to be accessed, and the request processing device may apply according to the destination.
  • the host port of the service queries the application state library. When the state of the destination application service is not started in the application state library, the request processing device stores the service access request and does not forward the message temporarily.
  • the target application is started by the container engine.
  • the destination container where the service is located, and monitors the application state library.
  • the application service monitoring module in the container monitors the state of the destination application service on the destination container.
  • the application service monitoring module in the container may modify the application state library to record the destination application service.
  • the status is started.
  • the request processing device can monitor that the status of the destination application service recorded in the application state library is started, and forward the previously stored service access request to the destination container. Since the application service has been started, when the container receives the service access request, the destination application service in the container can process the service access request.
  • the request processing device when the request processing device receives the service access request of the client, it determines whether the application service that processes the service access request has been started, and only determines the service access request when the status of the application service is started. Forward to the container to prevent the container from receiving a service access request before the application service is started, and failing to access the service access request.
  • the host further includes a routing table, where the routing table records a correspondence between a host port of the application service and a container port of the application service and an IP address of the container where the application service is located.
  • the internal network connection between the host and the container is established by using the routing table, and the container can be isolated from the public network.
  • the request processing apparatus may start the destination container by: querying the routing table according to the destination port of the application access request, and determining an IP address of the destination container where the destination application service is located, according to The IP address of the destination container starts the destination container through the container engine.
  • the request processing apparatus may forward the service access request by: querying the routing table according to the destination port of the application access request, and modifying the destination IP address of the service access request to the IP address of the container The address is used to modify the destination port of the service access request to the container port of the application service, and send the modified service access request to the destination container.
  • the request processing device when the request processing device determines that the status of the destination application service is started, the request processing device may directly send the service access request to the destination container without storing the service access request.
  • the container since the application service has been started, after receiving the service access request for the application service, the container does not need to be started again, so the container startup action is not repeated, but the service request is directly forwarded to the container. Processing to ensure the speed of request processing.
  • the present application provides a request processing apparatus, which is provided in a host, and includes the following functional modules:
  • a receiving module configured to receive a service access request of the client, where the destination port of the service access request is a host port of the destination application service to be accessed;
  • a container startup module configured to query an application state library according to a host port of the application service, and store a service access request when the state of the destination application service is not started, and start a destination container where the destination application service is located by using a container engine, where the application is The state library is used to record the state of the application service running in the container on the host;
  • the application state library monitoring module is configured to monitor the state of the destination application service recorded in the application state library
  • a sending module configured to: when the application state library monitoring module monitors that the state of the destination application service recorded in the application state library is started, forwarding the service access request stored by the container startup module to the destination container, so that the destination application service processing service The access request, wherein the state of the destination application service recorded in the application state library is updated by the application service monitoring module of the destination container after the startup of the destination application service is completed.
  • the request processing device when the request processing device receives the service access request of the client, it determines whether the application service that processes the service access request has been started, and only determines the service access request when the status of the application service is started. Forward to the container to prevent the container from receiving a service access request before the application service is started, and failing to access the service access request.
  • the host further includes a routing table, where the routing table records a correspondence between a host port of the application service and a container port of the application service and an IP address of the container where the application service is located.
  • the internal network connection between the host and the container is established by using the routing table, and the container can be isolated from the public network.
  • the container startup module is specifically configured to: according to the destination port of the application access request, query the routing table, determine the IP address of the destination container where the destination application service is located, and according to the IP address of the destination container Start the destination container through the container engine.
  • the sending module is specifically configured to: according to the destination port of the application access request, query the routing table, modify the destination IP address of the service access request to the IP address of the container, and access the service access request.
  • the destination port is modified to be the container port of the application service, and the modified service access request is sent to the destination container.
  • the container startup module is further configured to not store the service access request when the status of the query application service is started, and the sending module is further configured to directly access the service access request. Send to the destination container.
  • the present application provides a request processing method, which is applied to a host, where the host includes a host operating system, a request processing device, an application state library, and a destination container.
  • the host operating system includes a container engine, and the destination container runs in the container engine.
  • the destination container includes a destination application service, and the method includes:
  • the request processing device receives the service access request of the client, and the destination port of the service access request is a host port of the destination application service to be accessed;
  • the request processing device queries the application state library according to the host port of the destination application service, and stores the service access request when the state of the destination application service is not started, and starts the destination container where the destination application service is located by using the container engine;
  • the destination container monitors the state of the destination application service on the destination container.
  • the status of the application service is recorded in the application state library as started.
  • the request processing device forwards the stored service access request to the destination container when the state of the destination application service recorded in the application state library is monitored, so that the destination application service processes the service access request.
  • the host may also include other containers, and the other containers also run on the container engine.
  • the destination container is selected through the destination port of the service access request, and the destination port of the service access request is the target application service to be accessed.
  • the host port selects the container where the destination application service is located as the destination container.
  • the request processing device when the request processing device receives the service access request of the client, it determines whether the application service that processes the service access request has been started, and only determines the service access request when the status of the application service is started. Forward to the container to prevent the container from receiving a service access request before the application service is started, and failing to access the service access request.
  • the host further includes a routing table, where the routing table records a correspondence between a host port of the application service and a container port of the application service and an IP address of the container where the application service is located.
  • the internal network connection between the host and the container is established by using the routing table, and the container can be isolated from the public network.
  • the request processing device by using the container engine to start the destination container where the destination application service is located, specifically includes:
  • the request processing device queries the routing table according to the destination port of the application access request, determines the IP address of the destination container where the destination application service is located, and starts the destination container through the container engine according to the IP address of the destination container.
  • the request processing device forwarding the stored service access request to the destination container specifically includes:
  • the request processing device queries the routing table according to the destination port of the application access request, and modifies the destination IP address of the service access request to the IP address of the container, and modifies the destination port of the service access request to the container port of the application service, and the modified service is modified.
  • the access request is sent to the destination container.
  • the method further includes:
  • the request processing device queries that the state of the destination application service is started, the service access request is not stored, and the service access request is directly sent to the destination container.
  • the container since the application service has been started, after receiving the service access request for the application service, the container does not need to be started again, so the container startup action is not repeated, but the service request is directly forwarded to the container. Processing to ensure the speed of request processing.
  • the present application provides a method for processing a service access request, which is executed by a request processing device on a host, and includes the following steps: Step 1: Receive a service access request of a client, and the destination port of the service access request is to be Accessing the host port of the application service; Step 2: Query the application state library according to the host port of the destination application service. When the state of the destination application service is not started, the service access request is stored, and the destination application service is started by the container engine.
  • step 3 monitoring the application state library, when the state of the destination application service recorded in the application state library is started, the storage is The service access request is forwarded to the destination container, so that the destination application service processes the service access request after the startup is started, wherein the state of the destination application service recorded in the application state library is the application service monitoring module of the destination container after the target application service is started. updated.
  • the request processing device when the request processing device receives the service access request of the client, it determines whether the application service that processes the service access request has been started, and only determines the service access request when the status of the application service is started. Forward to the container to prevent the container from receiving a service access request before the application service is started, and failing to access the service access request.
  • the application provides a host, including a memory, a processor, and a bus.
  • the memory and the processor are respectively connected to a bus.
  • the memory stores a program instruction and an application state library, and the processor executes the first program instruction in the memory to implement Requesting a function of the processing device, the processor executing a second program instruction in the memory to implement a function of the application service monitoring module, the processor executing the first program instruction in the memory to perform the step of: receiving a service access request of the client, the service access request
  • the destination port is the host port of the service to be accessed.
  • the application port is queried according to the host port of the destination application service.
  • the service access request is stored, and the destination application service is started by the container engine.
  • the destination container the processor executes the second program instruction in the memory to perform the step of: monitoring the state of the destination application service on the destination container, and recording the status of the application service in the application state library to be started when the destination application service is started.
  • Processor execution The first program instruction in the device performs the step of: when monitoring the status of the destination application service recorded in the application state library to be activated, forwarding the stored service access request to the destination container, so that the destination application service processes the service access request .
  • the request processing device when the request processing device receives the service access request of the client, it determines whether the application service that processes the service access request has been started, and only determines the service access request when the status of the application service is started. Forward to the container to prevent the container from receiving a service access request before the application service is started, and failing to access the service access request.
  • the present application may further combine to provide more implementations.
  • FIG. 1 is a schematic structural diagram of a device of a host according to an embodiment of the present invention.
  • FIG. 2 is a data interaction flowchart of a method for processing a service access request according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of still another apparatus of a host according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of another device of a host according to an embodiment of the present invention.
  • the host 100 includes hardware 10, a host operating system 20, a request processing device 203, an application state library 202, a routing table 201, a container 30, and a container. 40.
  • the present embodiment is illustrated in two containers, and in some embodiments, the number of containers may be one or more than two.
  • the host operating system 20 includes a container engine 204 and a physical NIC driver 205.
  • the request processing device 203 can access the routing table 201 and the application state library 202.
  • request processing device 203 can be disposed in the kernel of host operating system 20, run through the kernel, and in other examples, request processing device 203 can be installed as application software to host operating system 20, in host operating system 20 run.
  • the application state library 202 and the routing table 201 can be stored in the disk of the host 100 and can be loaded onto the memory of the host 100.
  • the hardware 10 includes a physical network card 101.
  • the hardware 10 further includes a processor, a memory (not shown), and the like, and the hardware 10 carries the operation of the host operating system.
  • the physical network card driver 205 in the host operating system 20 is used to drive the physical network card 101.
  • the physical network card driver 205 is equivalent to the hardware interface of the physical network card 101.
  • the host operating system 20 controls the work of the physical network card 101 through the hardware interface, such as sending and receiving.
  • the IP address of the host 100 can be set by the physical network card 101.
  • the IP address is the public network address of the host 100.
  • the physical network card 101 can be configured with multiple public network addresses. In the embodiment of the present invention, only It is necessary to use one of the public network addresses, which may be, for example, 123.456.78.101 in this embodiment.
  • the destination address of the access request needs to be set to the public network address of the host 100, and the request processing device 203 forwards the access request to the corresponding container according to the forwarding rule recorded in the routing table 201.
  • the container can be isolated from the public network. If the service access request from the public network needs to access the container, the host 100 can only reach the host 100 and can be forwarded by the host 100 to reach the container.
  • the container 30 includes a virtual network card 301, an operating environment 302, an application service monitoring module 303, an application service 304, and an application service 305.
  • the container 40 includes a virtual network card 401, an operating environment 402, an application service monitoring module 403, and an application service 404.
  • the runtime environment is specifically a dependency package including Bins/Libs (binary or library) files, and different containers 30 and 40 have different dependency packages, so that different application services can run in the corresponding containers through the corresponding dependency packages.
  • the container 30 runs an application service monitoring module 303, an application service 304, and an application service 304 under the operating environment 302.
  • the container 40 runs the application service monitoring module 403 and the application service 404 under the operating environment 402.
  • the container 30 can provide all of the elements for the application services 305, 304 to run (the container 40 is also relative to the application service 404), and the container 30 and container 40 can be run, started, stopped (ie not started) under the control of the container engine 204 or It is deleted, and the container 30 and the container 40 are isolated security application platforms.
  • the request processing device 203 is configured to process a service access request sent by the client for an application service in a specific container.
  • the container engine 204 is embedded in the kernel of the host operating system 20 by installation, allowing the developer to package the application service 404 and the runtime environment 403 into the portable container 40, and/or to run the environment 302, the application service 304, and the application service. 305 is packaged into a portable container 40, and then the container 30 and/or container 40 is published to any popular Linux machine for virtualization.
  • the container engine 204 can provide the host operating system 20 with a bash instruction set for controlling the container in the shell interface, wherein the shell interface is a user interface of the host operating system 20 and provides the user and the host operating system 20 An interface for the kernel to interact.
  • the shell interface controls the container by receiving the bash instruction entered by the user and sending it to the kernel for execution.
  • the bash command input by the user can also be written into the script, and the host operating system 20 can automatically execute the bash command when the shell interface specifies the running time of the script (or automatically executes after the host operating system 20 is started).
  • the container engine 204 can also allocate a virtual network card 301 to the container 30, and assign a virtual network card 401 to the container 40.
  • the IP address of the container 30 can be set to 192.168.1.3 by the virtual network card 301
  • the container 40 can be set by the virtual network card 401.
  • the IP address is set to 192.168.1.4
  • the bridge 2041 is set in the container engine 204.
  • the virtual network card 301 and the virtual network card 401 are respectively connected to the bridge 2041.
  • the bridge 2041 identifies the container by the IP address of the container.
  • virtual network card 301 assigns port 21 to application service 305, port 80 to application service 304, application service 304 can be, for example, a web service, and application service 305 can be, for example, an Ftp service.
  • the bridge 2041 can forward the data sent by the virtual network card 301 or the virtual network card 401 to the physical network card driver 205.
  • the physical network card driver 205 encapsulates the data and sends the data to the external device through the physical network card 101. Further, after the physical network card 101 unpacks the data from the external device via the physical network card driver 205, it is sent to the bridge 2041 after being processed by the request processing device 203 (described in detail later), and sent to the container by the bridge 2041. 30 or container 40.
  • host 100 may assign port 12404 to application service 404 in host operating system 20, port 12305 to application service 305, and port 12304 to application service 304.
  • the routing table 201 pre-records:
  • Routing table 201 is shown in Table 1:
  • the container port of the application service can be directly allocated by the container in which it resides, and the host port of the application service can be allocated by the host running the container where the application service is located. In an alternative embodiment, the container port and the host port of the application service can be located by the container running the application service.
  • the host is uniformly allocated, or is allocated by a third-party platform, which is not limited by the embodiment of the present invention.
  • the role of the application state library 202 is to record the state of the application service running on each container on the host, which can be written by the request processing device 203 and the application service monitoring modules 303, 403 in each container, and by the request processing device 203. Read. It is worth noting that the container 30 is in the "not activated" state in the initial state, so the application service 304 and the application service 305 in the container 30 are also not activated, and the request processing device 203 detects the application service 304 and the application service through the container engine 204. 305 is not activated, and the application state library 202 is modified independently of the container 30, and the application state library 202 is modified so that the state of the record application service 304 is not started.
  • the application service 304 and the application service 404 are Web services, the name is apache, and the application service 305 is an Ftp service whose name is ftp.
  • part of the content in the application state library 202 should be at least as shown in Table 2:
  • Container identifier Application service identifier Status of the application service (Status) Container1 Apache Not started (stop) Container1 Ftp Not started (stop) Container2 Apache Not started (stop)
  • the container identifier can be implemented by, for example, a container name or a container network address
  • the application service identifier can be implemented by, for example, an application service name or a container port.
  • the container identification is implemented using a container name
  • the application service identification is implemented using an application service name (app name).
  • containername is the container name
  • appname is the application service name
  • status is the application service state
  • container1 is the name of the container 30
  • apache is the name of the application service 304 of the container 30.
  • Stop indicates that the application service 304 is not started; in the third row of Table 2, container1 is the name of the container 30, ftp is the name of the application service 305 of the container 30, and stop indicates that the application service 305 is not started; in the fourth row of the table 2 Container2 is the name of the container 40, apache is the name of the application service 404 of the container 40, and run indicates that the application service 305 has been started.
  • the storage path of the application state library 202 is "/myapp", ie the application state library 202 is stored in the directory myapp of the host operating system 20. It is worth noting that the directory name can be set as needed, and in the myapp directory, only one file of the application state library 202 exists.
  • FIG. 2 is a data interaction flowchart of a method for processing a service access request according to an embodiment of the present invention. The solution provided by the embodiment will be described below with reference to FIG. 2 .
  • section 501 container 30 is in an "unstarted” state.
  • the request processing device 203 can input a container stop command to the container engine 204, thereby causing the container 30 to be in an "unstarted” state. Specifically, the request processing device 203 can input a container stop command to the container engine 204 through the shell interface of the host operating system 20. Docker stop container1", container1 is the name of container 30.
  • request processing device 203 sends a container status detection command to container engine 204.
  • the container status detection commands are, for example, "docker ps-a” and “docker ps”, the command “docker ps-a” lists the containers in the “not started” state, and the command “docker ps” can be listed as “started” The container of the state.
  • the request processing means 203 can input the container stop command "docker stop container1" to the container engine 204 through the shell interface of the host operating system 20.
  • the container engine 204 runs a container status detection command to detect the status of the container and detects that the container 30 is in the "not activated” state and the container 40 is in the "activated” state.
  • the container engine 204 notifies the request processing device 203 of the information that the container 30 is in the "not activated” state, and the container engine 204 can notify the request processing device 203 of the information that the container 40 is in the "activated” state.
  • the request processing device 203 after learning that the container 30 is in the "not started” state, modifies the application state library 202 to record the status of the application services 304 and 305 as "not started.” Further, after the request processing device 203 learns that the container 40 is in the "activated” state, the request processing device 203 detects that the application service 404 has been started by the container engine 204, modifies the application state library 202, and modifies the application state library 202 to record. The status of the application service 404 is "started".
  • the request processing device 203 sends an application service status query instruction to the container 40 through the container engine 204, and the container 40 inputs a "ps" command in its own shell interface to query the status of the application service 404, and learns that it is started, request processing.
  • the device 203 obtains the status of the application service 404 through the container engine 204 as "enabled”.
  • the modified application state library 202 is as shown in Table 3:
  • Container identifier Application service identifier Status of the application service (Status) Container1 Apache Not started (stop) Container1 Ftp Not started (stop) Container2 Apache Started (run)
  • the application service state recorded by the application state library 202 can be updated to be consistent with the state of the current application service, and the updated application state library 202 can be used in the following steps 506-514.
  • the request processing device 203 executes the "etcdctl set/myapp/container1/apache/status"stop”" command through the shell interface of the host operating system 20 to modify the "/myapp" storage path.
  • the state library 202 is applied, and the state of the application service named “apache” in the container 30 named “container1" in the application state library 202 is recorded as "stop” (ie, as shown in the second row of Table 2) .
  • the request processing device 203 executes the "etcdctl set/myapp/container1/ftp/status"stop"" command through the shell interface of the host operating system 20 to modify the application state library 202 located in the "/myapp" storage path, and
  • the state of the application service named "ftp” on the container 30 named “container1" in the application state library 202 is recorded as "stop" (i.e., as shown in the second row of Table 2).
  • the request processing device 203 executes the "etcdctl set/myapp/container2/apache/status"start”" command through the shell interface of the host operating system 20, and applies the state library 202 to the container 40 named "container2".
  • the status of the application service named "apache” is recorded as "start” (that is, as shown in the third line of Table 2).
  • the request processing device 203 knows that all the applications in the container 1 are obtained by querying the application state library 202 when the container 30 (container 1) is in the "not activated” state and the container 40 (container 2) is in the "activated” state.
  • the name of the service apache and ftp, and the name of all application services in container2: apache.
  • request processing device 203 receives a service access request.
  • the service access request is sent by an external device (such as a client) for the application service 304 in the container 30.
  • a service access request is first received by the physical network card 101 in FIG. 1, and sent to the request processing device 203 via the physical network card driver 205.
  • the parsed service access request may include a destination IP address, a destination port, a source IP address, a source port, and a request type, and the request type includes but is not limited to a read request, a write request, a connection request, a download request, a test request, and the like.
  • the destination IP address is the external network IP address of the host 100
  • the destination port is the host port of the application service 304
  • the source IP address and the source port are the IP addresses and ports of the terminal that sends the service access request to the host 100.
  • the service access request may be a webpage access request (http request), the request type is a read request, the destination IP address is 123.456.78.101 (the external network IP address of the host 100), and the destination port is 12304 (application service 304 Host port), the source IP address is 123.456.98.102 (the IP address of the external device), and the source port is 8012.
  • Application service 304 can be web server software, such as apache software.
  • the service access request is a download request (ftp request) or other common network request.
  • the service access request of the request processing device 203 is a web page access request.
  • the request processing device 203 resolves the destination port of the service access request to the host port 12304 of the application service 404, and queries the container address 192.168.1.3 corresponding to the port 12304 in the routing table 201.
  • the container address 192.168.1.3 the name of the container 30 is known (for example, container1), and the state of the application service of the container container1 is queried in the application state table 202.
  • the request processing device 203 Since the states of the application services apache and ftp in the container1 are both "not started", It can therefore be determined that the container 30 is in the "not started” state (see section 505), at which point the container 30 needs to be started, so the request processing device 203 stores the service access request, waiting for the application service 404 to start and then forwarding the service access request. Specifically, in section 507, request processing device 203 sends a container launch command to container engine 204. The container startup command is "docker start container1", and the request processing device 203 executes the "docker start container1" command through the shell interface of the host operating system 20.
  • the request processing device 203 pre-records the correspondence between the IP address 192.168.1.3 of the container 30 and the name of the container 30 (such as container1), and obtains the name container1 of the container 30 from the IP address 192.168.1.3 of the container 30. .
  • the application state library 202 can be partially monitored at 508. The portion 508 can be executed after the container launch command is sent or in synchronization with the send container launch command.
  • the request processing device 203 can perform monitoring of the application state library 202 by executing a "confd/myapp" command through the shell interface of the host operating system 20, "/myapp" is the path where the application state library 202 is located, and the application state library 202 is stored in the path.
  • the path directory of the application state library may also be other paths, which is not limited by the embodiment of the present invention.
  • the request processing device 203 can detect a status change of the application state library 202.
  • the container engine 204 starts the container 30 in accordance with the container launch command.
  • the startup speed of the container 30 is in the order of seconds.
  • container 30 launches application services 304 and 305 and monitors whether application services 304 and 305 have completed booting.
  • the application services 304 and 305 can be set by script to realize automatic startup after the container 30 is started.
  • the application service monitoring module 303 shown in FIG. 1 can be used to monitor whether the application services 304 and 305 are completed, and the application service monitoring module 303 passes.
  • the shell interface of the container 30 executes an application service startup command, and the application service startup command may be, for example, a "start" command, and its usage is "application service path /bin/application service name start".
  • the application service monitoring module 303 can further execute the "curllocalhost:port/appname/index.html" command through the shell interface of the container 30 to monitor whether the application service 304 or 305 is started.
  • the localhost refers to the container 30 itself
  • the port is the port allocated by the container 30 for the application service (port 80 for the application service 304, port 21 for the application service 305)
  • the appname is the application service name (for the application service 304 is apache, for Application service 305 is ftp), which can be used to monitor whether application service 304 or 305 on container 30 is up to completion.
  • the application service 304 is a webpage service software, it is necessary to perform operations such as connecting a database and reading a configuration file, so that it takes longer to start up than the container 30 starts up.
  • Section 511 after the container 30 confirms that the application services 304 and 305 have completed startup, the status of the application services 304 and 305 recorded by the application state library 202 is updated to have been initiated.
  • the application service monitoring module 303 in the container 30 modifies the application state library 202 located in the "/myapp” directory by executing the "etcdctlset/myapp/container1/apache/status”run”” command to the shell interface of the container 30. And modify the state of the application service 304 named “apache” corresponding to "container1" in the application state library 202 to "run” (started).
  • the application service monitoring module 303 also executes the "etcdctl set/myapp/container1/ftp/status"run”" command to the shell interface of the container 30, and the name “ftp” corresponding to "container1" in the application state library 202.
  • the status of the application service 305 is modified to "run".
  • section 512 since the state of the application service 304 in the application state library 202 is modified to have been initiated, the change in state is detected by the request processing device 203 (see step 508), at which point the request processing device 203 will access the service. The request is forwarded to the container 30.
  • the "forwarding" as used herein means that the request processing device 203 searches the routing table 201 for the IP address of the container 30 corresponding to the destination port 12304 according to the destination port 12304 carried by the service access request.
  • the container port (192.168.1.3:80) of the application service 304 is modified to change the destination IP address 123.456.78.101 of the service access request to the IP address 192.168.1.3 of the container 30, and the destination port 12304 to the container port 80 of the application service 304.
  • the bridge 2041 accesses the service according to the IP address 192.168.1.3 of the container 30 carried by the service access request and the container port 80 of the application service 304.
  • the request is sent to the port 80 of the virtual network card 301 of the container 30, thereby causing the application service 304 to receive an application service request at the port 80, thereby processing the application service request.
  • request processing device 203 receives another service access request for application service 304 disposed within container 30, which may be, for example, another web page access request.
  • the request processing device 203 determines that the destination port of the other service access request is the host port 12304 of the application service 404, and queries the container address 192.168.1.3 corresponding to the port 12304 in the routing table 201, and learns according to the container address 192.168.1.3.
  • the request processing device 203 may query the status of the application service 304 in the application state library 202 before forwarding another service access request. Specifically, in the table 2, the status of the apache of the container 1 is "run”. When the system is started, another service access request can be forwarded directly to the container 30. If it is "stop", the parts 507 to 511 need to be executed to start the container 30.
  • the request processing device when the request processing device receives the service access request of the client, it determines whether the application service that processes the service access request has been started, and only determines the service access request when the status of the application service is started. Forward to the container to prevent the container from receiving a service access request before the application service is started, and failing to access the service access request.
  • the request processing device 203 receives the service access request for the application service 404, the service access request of the application service 304 can be forwarded according to the state of the application service 404 in the application state library 202. Specifically, when the status of the apache of the container 2 in the table 2 is "run", the service access request for the application service 304 is directly forwarded to the container 40, because the request processing device 203 is skipped. Processing, so you can guarantee the processing speed of the request.
  • FIG. 3 shows the internal structure of the request processing device 203.
  • the processing device 203 includes a receiving module 101, a container starting module 102, an application state library monitoring module 103, and a transmitting module 104.
  • the receiving module 101 can perform the functions described in the above sections 506 and 513, and the container starting module 102 can perform the functions described in the above sections 502 and 507, and the application state library monitoring module 103 can perform the functions described in the above section 508 and send Module 104 may perform the functions described in sections 512 and 514 above.
  • the above functional modules can be implemented by scripts, and the scripts can be run on the shell interface of the host operating system 20 to implement corresponding functions.
  • FIG. 4 is a schematic structural diagram of a device of a host 100 according to an embodiment of the present invention.
  • the master host 100 includes a memory 602, a processor 601, and a bus 603.
  • the memory 602 and the processor 601 are respectively connected to a bus 603.
  • the memory 602 stores program instructions and an application state library 202.
  • the processor 601 executes the first program instructions in the memory 602 to implement the functions of the request processing device 203, and the processor 601 executes The second program instruction in the memory 602 implements the function of the application service monitoring module 303, 403, and the processor 601 executes the first program instruction in the memory 602 to perform the step of receiving the service access request of the client, and the destination port of the service access request is The host port of the destination application service to be accessed; the application state library 202 is queried according to the host port of the destination application service, and when the state of the destination application service is not started, the service access request is stored, and the purpose of the destination application service is started by the container engine.
  • the processor 601 executes a second program instruction in the memory 602 to perform the step Monitoring the status of the destination application service on the destination container.
  • the state of the application service is recorded in the application state library 202 as being started; the processor 601 executes the first program instruction in the memory 602 to perform the step.
  • the stored service access request is forwarded to the destination container, so that the destination application service processes the service access request.
  • the service access request is forwarded to the container by determining the service access request when the status of the application service is started.
  • the application service in the container is not received until the application service is started, so that the application service can be Business access requests are processed to ensure that business access requests are not lost because the container is starting too fast.
  • the host further includes a routing table 201, where the routing table 201 records the correspondence between the host port of the application service and the container port of the application service and the IP address of the container where the application service is located.
  • the processor 601 executes the first program instruction in the memory 602 to perform a specific step to start the destination container: according to the destination port of the application access request, query the routing table 201, and determine the IP address of the destination container where the destination application service is located, The destination container is started by the container engine according to the IP address of the destination container.
  • the processor 601 executes the first program instruction in the memory 602 to perform a specific step of forwarding the service access request: querying the routing table 201 according to the destination port of the application access request, and modifying the destination IP address of the service access request into a container The IP address of the service access request is modified to the container port of the application service, and the modified service access request is sent to the destination container.
  • the processor 601 executes the first program instruction in the memory 602 to perform the step of: when the state of the destination application service is started, the service access request is not stored, and the service access request is directly sent to the destination container.
  • FIG. 4 introduces the hardware architecture of the host in detail, and the functions and effects of the host shown in FIG. 4 are completely consistent with FIG. 1 and its corresponding contents, and details are not described herein.
  • any of the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as the cells may or may not be Physical units can be located in one place or distributed to multiple network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • connection relationship between the modules indicates that there is a communication connection between them, and specifically, one or more communication buses or signal lines can be realized.
  • the present invention can be implemented by means of software plus necessary general hardware, and of course, dedicated hardware, dedicated CPU, dedicated memory, dedicated memory, Special components and so on.
  • functions performed by computer programs can be easily implemented with the corresponding hardware, and the specific hardware structure used to implement the same function can be various, such as analog circuits, digital circuits, or dedicated circuits. Circuits, etc.
  • software program implementation is a better implementation in more cases.
  • the technical solution of the present invention which is essential or contributes to the prior art, can be embodied in the form of a software product stored in a readable storage medium, such as a floppy disk of a computer.
  • U disk mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., including a number of instructions to make a computer device (may be A personal computer, server, or network device, etc.) performs the methods described in various embodiments of the present invention.
  • a computer device may be A personal computer, server, or network device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Stored Programmes (AREA)
  • Computer And Data Communications (AREA)

Abstract

本发明实施例提供一种业务访问请求的处理方法和相关设备。该方法包括:请求处理装置接收客户端的业务访问请求;请求处理装置根据目的应用服务的主机端口,查询应用状态库,当目的应用服务的状态为未启动时,存储业务访问请求,通过容器引擎启动目的应用服务所在的目的容器;目的容器监控目的容器上的目的应用服务的状态,当目的应用服务启动完成时,在应用状态库中记录应用服务的状态为已启动;请求处理装置在监控到应用状态库中记录的目的应用服务的状态为已启动时,将存储的业务访问请求转发给目的容器,以使得目的应用服务处理业务访问请求。通过以上方式可避免容器在应用服务启动完成前接收到业务访问请求带来的访问失败的问题。

Description

业务访问请求的处理方法和相关设备 技术领域
本发明涉及信息技术领域,特别涉及一种业务访问请求的处理方法和相关设备。
背景技术
容器作为一种新兴的虚拟化方式,跟传统的虚拟化方式相比具有众多的优势,其中一个特性是轻量级,可以实现更快速的交付和部署。容器的启动时间通常是秒级的,从而可大量地节约业务上线的时间。
容器运行在主机的容器引擎上,对外提供访问端口,主机在接收到客户端发送给容器的业务访问请求时,将业务访问请求转发到容器上,由容器中的应用服务处理业务访问请求。
虽然容器可以做到秒级启动,但容器中的应用服务却无法做到秒级启动。具体的,应用服务在启动过程中需要读取相关的配置文件,加载依赖文件,以及连接数据库,因此应用服务的启动时间相对于容器而言需时较长。
在现有技术中,当容器未启动,而主机接收到针对容器内的应用服务的业务访问请求时,会启动容器,并直接转发该业务访问请求至容器,由于容器的启动速度很快,因此当业务访问请求发送至容器中时,容器已经启动,但是由于容器中的应用服务的启动时间较长,因此,当容器接收到业务访问请求时,处理该业务访问请求的应用服务可能仍然处在加载过程中,并未完成启动,从而导致业务访问请求无法得到处理,客户端对该应用服务的访问失败。
发明内容
本发明实施例提供一种业务访问请求的处理方法和相关设备,使得容器只有在应用服务启动完成后才会接收到业务访问请求,避免容器在应用服务启动完成前接收到业务访问请求带来的访问失败的问题。
第一方面,本申请提供一种主机,包括主机操作系统、请求处理装置、应用状态库以及容器,主机操作系统包括容器引擎,容器运行在容器引擎之上,容器包括应用服务和应用服务监控模块,应用状态库可记录容器中运行的应用服务的状态,请求处理装置接收客户端的业务访问请求,且业务访问请求的目的端口为待访问的目的应用服务的主机端口,请求处理装置可根据目的应用服务的主机端口来查询应用状态库,当在应用状态库中查询到目的应用服务的状态为未启动时,请求处理装置会存储业务访问请求而暂时不进行转发,此时通过容器引擎启动目的应用服务所在的目的容器,并监控应用状态库。在容器启动后,容器中的应用服务监控模块则监控目的容器上的目的应用服务的状态,当目的应用服务启动完成时,容器中的应用服务监控模块可修改应用状态库以记录目的应用服务的状态为已启动,此时,请求处理装置可监控到应用状态库中记录的目的应用服务的状态为已启动,将原先存储的业务访问请求转发给目的容器。由于应用服务已启动完成,因此,当容器接收到业务访问请求时,容器中的目的应用服务即可处理该 业务访问请求。
通过实施上述实施例,当请求处理装置接收到客户端的业务访问请求时,会判断处理该业务访问请求的应用服务是否已启动,只有在确定应用服务的状态为已启动时,才将业务访问请求转发至容器,避免容器在应用服务启动完成前接收到业务访问请求,无法对业务访问请求进行处理带来的访问失败的问题。
在第一方面的一种可能的实现方式中,主机还包括路由表,路由表记录有应用服务的主机端口与应用服务的容器端口以及应用服务所在的容器的IP地址之间的对应关系。
通过实施上述实施例,利用路由表建立主机与容器之间的内部网络连接,可将容器从公网隔离。
在第一方面的一种可能的实现方式中,请求处理装置可通过以下方式来启动目的容器:根据应用访问请求的目的端口来查询路由表,确定目的应用服务所在的目的容器的IP地址,根据目的容器的IP地址通过容器引擎启动目的容器。
在第一方面的一种可能的实现方式中,请求处理装置可通过以下方式转发业务访问请求:根据应用访问请求的目的端口,查询路由表,将业务访问请求的目的IP地址修改为容器的IP地址,将业务访问请求的目的端口修改为应用服务的容器端口,将修改后的业务访问请求发送给目的容器。
在第一方面的一种可能的实现方式中,请求处理装置在判断到目的应用服务的状态为已启动时,可不存储业务访问请求,而直接将业务访问请求发送给目的容器。
通过实施本实施例,由于应用服务已经启动,因此在接收到针对应用服务的业务访问请求后,无需再次启动容器,故不再重复执行容器启动之动作,而是将该业务请求直接转发至容器进行处理,可确保请求处理的速度。
第二方面,本申请提供一种请求处理装置,该请求处理装置设置于主机,其包括以下功能模块:
接收模块,用于接收客户端的业务访问请求,业务访问请求的目的端口为待访问的目的应用服务的主机端口;
容器启动模块,用于根据目的应用服务的主机端口,查询应用状态库,当目的应用服务的状态为未启动时,存储业务访问请求,通过容器引擎启动目的应用服务所在的目的容器,其中,应用状态库用于记录主机上的容器中运行的应用服务的状态;
应用状态库监控模块,用于监控应用状态库中记录的目的应用服务的状态;
发送模块,用于在应用状态库监控模块监控到应用状态库中记录的目的应用服务的状态为已启动时,将容器启动模块存储的业务访问请求转发给目的容器,以使得目的应用服务处理业务访问请求,其中,应用状态库中记录的目的应用服务的状态为目的容器的应用服务监控模块在目的应用服务启动完成后更新的。
通过实施上述实施例,当请求处理装置接收到客户端的业务访问请求时,会判断处理该业务访问请求的应用服务是否已启动,只有在确定应用服务的状态为已启动时,才将业务访问请求转发至容器,避免容器在应用服务启动完成前接收到业务访问请求,无法对业务访问请求进行处理带来的访问失败的问题。
在第二方面的一种可能的实现方式中,主机还包括路由表,路由表记录有应用服务的主机端口与应用服务的容器端口以及应用服务所在的容器的IP地址之间的对应关系。
通过实施上述实施例,利用路由表建立主机与容器之间的内部网络连接,可将容器 从公网隔离。
在第二方面的一种可能的实现方式中,容器启动模块具体用于:根据应用访问请求的目的端口,查询路由表,确定目的应用服务所在的目的容器的IP地址,根据目的容器的IP地址通过容器引擎启动目的容器。
在第二方面的一种可能的实现方式中,发送模块具体用于:根据应用访问请求的目的端口,查询路由表,将业务访问请求的目的IP地址修改为容器的IP地址,将业务访问请求的目的端口修改为应用服务的容器端口,将修改后的业务访问请求发送给目的容器。
在第二方面的一种可能的实现方式中,容器启动模块,还用于在查询到目的应用服务的状态为已启动时,不存储业务访问请求;发送模块,还用于直接将业务访问请求发送给目的容器。
第三方面,本申请提供一种请求处理方法,该方法应用于主机,主机包括主机操作系统、请求处理装置、应用状态库以及目的容器,主机操作系统包括容器引擎,目的容器运行在容器引擎之上,目的容器包括目的应用服务,该方法包括:
请求处理装置接收客户端的业务访问请求,业务访问请求的目的端口为待访问的目的应用服务的主机端口;
请求处理装置根据目的应用服务的主机端口,查询应用状态库,当目的应用服务的状态为未启动时,存储业务访问请求,通过容器引擎启动目的应用服务所在的目的容器;
目的容器监控目的容器上的目的应用服务的状态,当目的应用服务启动完成时,在应用状态库中记录应用服务的状态为已启动;
请求处理装置在监控到应用状态库中记录的目的应用服务的状态为已启动时,将存储的业务访问请求转发给目的容器,以使得目的应用服务处理业务访问请求。
其中,主机还可以包括其他容器,其他容器也运行于容器引擎之上,本发明实施例通过业务访问请求的目的端口来选择目的容器,在业务访问请求的目的端口为待访问的目的应用服务的主机端口时,选择目的应用服务所在容器为目的容器。
通过实施上述实施例,当请求处理装置接收到客户端的业务访问请求时,会判断处理该业务访问请求的应用服务是否已启动,只有在确定应用服务的状态为已启动时,才将业务访问请求转发至容器,避免容器在应用服务启动完成前接收到业务访问请求,无法对业务访问请求进行处理带来的访问失败的问题。
在第三方面的一种可能的实现方式中,主机还包括路由表,路由表记录有应用服务的主机端口与应用服务的容器端口以及应用服务所在的容器的IP地址之间的对应关系。
通过实施上述实施例,利用路由表建立主机与容器之间的内部网络连接,可将容器从公网隔离。
在第三方面的一种可能的实现方式中,请求处理装置通过容器引擎启动目的应用服务所在的目的容器具体包括:
请求处理装置根据应用访问请求的目的端口,查询路由表,确定目的应用服务所在的目的容器的IP地址,根据目的容器的IP地址通过容器引擎启动目的容器。
在第三方面的一种可能的实现方式中,请求处理装置将存储的业务访问请求转发给目的容器具体包括:
请求处理装置根据应用访问请求的目的端口,查询路由表,将业务访问请求的目的 IP地址修改为容器的IP地址,将业务访问请求的目的端口修改为应用服务的容器端口,将修改后的业务访问请求发送给目的容器。
在第三方面的一种可能的实现方式中,该方法还包括:
当请求处理装置查询到目的应用服务的状态为已启动时,不存储业务访问请求,直接将业务访问请求发送给目的容器。
通过实施本实施例,由于应用服务已经启动,因此在接收到针对应用服务的业务访问请求后,无需再次启动容器,故不再重复执行容器启动之动作,而是将该业务请求直接转发至容器进行处理,可确保请求处理的速度。
第四方面,本申请提供一种业务访问请求的处理方法,该处理方法由主机上的请求处理装置执行,包括如下步骤:步骤一、接收客户端的业务访问请求,业务访问请求的目的端口为待访问的目的应用服务的主机端口;步骤二:根据目的应用服务的主机端口,查询应用状态库,当目的应用服务的状态为未启动时,存储业务访问请求,通过容器引擎启动目的应用服务所在的目的容器,其中应用状态库用于记录主机上的容器中运行的应用服务的状态;步骤三、监控应用状态库,当应用状态库中记录的目的应用服务的状态为已启动时,将存储的业务访问请求转发给目的容器,以使得目的应用服务在完成启动后处理业务访问请求,其中,应用状态库中记录的目的应用服务的状态为目的容器的应用服务监控模块在目的应用服务启动完成后更新的。
通过实施上述实施例,当请求处理装置接收到客户端的业务访问请求时,会判断处理该业务访问请求的应用服务是否已启动,只有在确定应用服务的状态为已启动时,才将业务访问请求转发至容器,避免容器在应用服务启动完成前接收到业务访问请求,无法对业务访问请求进行处理带来的访问失败的问题。
第五方面,本申请提供一种主机,包括存储器、处理器和总线,存储器和处理器分别与总线连接,存储器存储有程序指令以及应用状态库,处理器执行存储器中的第一程序指令以实现请求处理装置的功能,处理器执行存储器中的第二程序指令以实现应用服务监控模块的功能,处理器执行存储器中的第一程序指令以执行步骤:接收客户端的业务访问请求,业务访问请求的目的端口为待访问的目的应用服务的主机端口;根据目的应用服务的主机端口,查询应用状态库,当目的应用服务的状态为未启动时,存储业务访问请求,通过容器引擎启动目的应用服务所在的目的容器;处理器执行存储器中的第二程序指令以执行步骤:监控目的容器上的目的应用服务的状态,当目的应用服务启动完成时,在应用状态库中记录应用服务的状态为已启动;处理器执行存储器中的第一程序指令以执行步骤:在监控到应用状态库中记录的目的应用服务的状态为已启动时,将存储的业务访问请求转发给目的容器,以使得目的应用服务处理业务访问请求。
通过实施上述实施例,当请求处理装置接收到客户端的业务访问请求时,会判断处理该业务访问请求的应用服务是否已启动,只有在确定应用服务的状态为已启动时,才将业务访问请求转发至容器,避免容器在应用服务启动完成前接收到业务访问请求,无法对业务访问请求进行处理带来的访问失败的问题。本申请在上述各方面提供的实现方式的基础上,还可以进行进一步组合以提供更多实现方式。
附图说明
为了更清楚地说明本发明实施例的技术方案,下面将对本发明实施例中所需要使用 的附图作简单地介绍,显而易见地,下面所描述的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是根据本发明实施例的主机的装置结构示意图;
图2是根据本发明实施例的业务访问请求的处理方法的数据交互流程图;
图3根据本发明实施例的主机的又一装置结构示意图;
图4是根据本发明实施例的主机的另一装置结构示意图。
具体实施方式
图1为根据本发明实施例的主机的装置结构示意图,如图1所示,主机100包括硬件10、主机操作系统20、请求处理装置203、应用状态库202、路由表201、容器30以及容器40。
值得说明的是,本实施例以2个容器进行说明,而在一些实施例中,容器的数量可以是1个或大于2个。
主机操作系统20包括容器引擎204以及物理网卡驱动205。请求处理装置203可访问路由表201和应用状态库202。
在一些示例中,请求处理装置203可设置在主机操作系统20的内核,通过内核运行,在另外一些示例中,请求处理装置203可作为应用软件安装到主机操作系统20,在主机操作系统20中运行。应用状态库202和路由表201可存储于主机100的磁盘中,并可加载到主机100的内存上。
硬件10包括物理网卡101,硬件10还包括处理器、存储器(图未示出)等,硬件10承载主机操作系统的运行。
而主机操作系统20中的物理网卡驱动205用于驱动物理网卡101,物理网卡驱动205相当于物理网卡101的硬件接口,主机操作系统20通过该硬件接口控制物理网卡101的工作,如发送、接收数据,可通过物理网卡101为主机100设置IP地址,该IP地址为主机100的公网地址(在一些实施例中,物理网卡101可设置多个公网地址,在本发明实施例中,只需使用其中一个公网地址即可),在本实施例中可例如为123.456.78.101。外部设备若要访问容器30或40,需将访问请求的目的地址设定为主机100的公网地址,请求处理装置203根据路由表201记录的转发规则将访问请求转发至对应容器。通过设置路由表201,可将容器从公网隔离,来自公网的业务访问请求若要访问容器,只能先到达主机100,经主机100转发才能到达容器。
容器30包括虚拟网卡301、运行环境302、应用服务监控模块303、应用服务304以及应用服务305,容器40包括虚拟网卡401、运行环境402、应用服务监控模块403以及应用服务404。运行环境具体为包括Bins/Libs(二进制或库)文件的依赖包,不同的容器30和40具有不同的依赖包,从而令不同的应用服务通过对应依赖包可正常运行在对应的容器中。
容器30在运行环境302下运行应用服务监控模块303、应用服务304和应用服务304,容器40在运行环境402下运行应用服务监控模块403和应用服务404。容器30可以为应用服务305、304运行提供一切要素(容器40相对于应用服务404亦然),容器30和容器40可以在容器引擎204的控制下可以运行、启动、停止(即未启动)或者被删除,容 器30与容器40之间是隔离的安全应用平台。
请求处理装置203用于对客户端发送的针对特定容器内的应用服务的业务访问请求进行处理。容器引擎204通过安装而嵌入于主机操作系统20的内核,可让开发者将应用服务404以及运行环境403打包到可移植的容器40中,和/或将运行环境302、应用服务304和应用服务305打包到可移植的容器40中,然后将容器30和/或容器40发布到任何流行的Linux机器上,从而实现虚拟化。
在安装容器引擎204之后,容器引擎204可于shell接口中为主机操作系统20提供控制容器的bash指令集,其中Shell接口是主机操作系统20的用户界面,是提供了用户与主机操作系统20的内核进行交互操作的一种接口。Shell接口接收用户输入的bash指令并将其送入内核去执行,从而控制容器。并且,用户输入的bash指令也可以写入到脚本中,在Shell接口指定脚本的运行时间(或指定主机操作系统20启动后自动执行),可令主机操作系统20自动执行bash指令。
容器引擎204还可以为容器30分配虚拟网卡301,为容器40分配虚拟网卡401,举例而言,可通过虚拟网卡301将容器30的IP地址设置为192.168.1.3,通过虚拟网卡401将容器40的IP地址设置为192.168.1.4,容器引擎204内设置了网桥2041,虚拟网卡301、虚拟网卡401分别与网桥2041连接,网桥2041通过容器的IP地址识别容器。
示例性地,虚拟网卡301为应用服务305分配端口21,为应用服务304分配端口80,应用服务304举例而言可为Web服务,应用服务305举例而言可为Ftp服务。
网桥2041可将虚拟网卡301或虚拟网卡401发出的数据转发至物理网卡驱动205,物理网卡驱动205对该数据进行封装后通过物理网卡101发送至外部设备。进一步,物理网卡101从外部设备接收的数据经物理网卡驱动205拆包之后,在经由请求处理装置203的处理(下文将会详细描述)后发送至网桥2041,并由网桥2041发送至容器30或容器40。
示例性地,主机100可在主机操作系统20中为应用服务404分配端口12404,为应用服务305分配端口12305,为应用服务304分配端口12304。
在本发明实施例中,路由表201预先记录了:
容器30的IP地址192.168.1.3、应用服务304的容器端口80二者与主机应用服务304的主机端口12304之间的对应关系;
容器30的IP地址192.168.1.3、应用服务305的容器端口21二者与主机应用服务305的主机端口12305之间的对应关系;
容器40的IP地址192.168.1.4、应用服务404的容器端口80二者与主机应用服务404的主机端口12404之间的对应关系。
路由表201如表1所示:
192.168.1.3:80 12304
192.168.1.3:21 12305
192.168.1.4:80 12404
表1
应用服务的容器端口可以由所在容器直接分配,应用服务的主机端口可以由运行应用服务所在容器的主机分配,在可选实施例中,应用服务的容器端口和主机端口可由运 行应用服务的容器所在主机统一分配,或由第三方平台分配,本发明实施例对此不作限定。
应用状态库202的作用是记录本主机上的各容器上运行的应用服务的状态,其可以由请求处理装置203及各容器中的应用服务监控模块303、403写入,并由请求处理装置203读取。值得注意的是,容器30在初始状态下处于”未启动”状态,因此容器30中的应用服务304和应用服务305也未启动,请求处理装置203通过容器引擎204检测到应用服务304和应用服务305未启动,会对独立于容器30之外的应用状态库202进行修改,修改应用状态库202使其记录应用服务304的状态为未启动。
假设应用服务304和应用服务404为Web服务,其名称为apache,应用服务305为Ftp服务,其名称为ftp,在初始状态下,应用状态库202中的部分内容至少应如表2所示:
容器标识 应用服务标识 应用服务的状态(Status)
container1 apache 未启动(stop)
container1 ftp 未启动(stop)
container2 apache 未启动(stop)
表2
容器标识举例而言可通过容器名称或容器网络地址来实现,应用服务标识举例而言可通过应用服务名称或容器端口来实现。
示例地,在表2中,利用容器名称(container name)来实现容器标识,利用应用服务名称(app name)来实现应用服务标识。在表2的第一行,containername为容器名称,appname为应用服务名称,status为应用服务状态;在表2的第二行,container1为容器30的名称,apache为容器30的应用服务304的名称,stop表示应用服务304未启动;在表2的第三行,container1为容器30的名称,ftp为容器30的应用服务305的名称,stop表示应用服务305未启动;在表2的第四行,container2为容器40的名称,apache为容器40的应用服务404的名称,run表示应用服务305已启动。在一示例中,应用状态库202的存储路径为“/myapp”,即应用状态库202存储在主机操作系统20的目录myapp中。值得注意的是,该目录名称可根据需要设置,且在myapp目录下,仅存在应用状态库202一个文件。
图2是根据本发明实施例的业务访问请求的处理方法的数据交互流程图,以下将结合图2对实施例提供的方案进行说明。
在500部分,容器40处于“已启动”状态。
在501部分,容器30处于“未启动”状态。
请求处理装置203可向容器引擎204输入容器停止命令,从而使得容器30处于”未启动”状态,具体地,请求处理装置203可通过主机操作系统20的shell接口向容器引擎204输入容器停止命令“docker stop container1”,container1为容器30的名称。
在502部分,请求处理装置203发送容器状态检测命令至容器引擎204。
容器状态检测命令例如为“docker ps-a”和“docker ps”,命令“docker ps-a”可列出处于“未启动”状态的容器,命令“docker ps”可列出处于“已启动”状态的容器。请求处理装置203可通过主机操作系统20的shell接口向容器引擎204输入容器停止命令“docker stop  container1”。在503部分,容器引擎204运行容器状态检测命令以检测容器状态,并检测到容器30处于“未启动”状态,且容器40处于“已启动”状态。
在504部分,容器引擎204将容器30处于”未启动”状态的信息通知请求处理装置203,并且,容器引擎204可将容器40处于“已启动”状态的信息通知请求处理装置203。
在505部分,请求处理装置203在获知容器30处于”未启动”状态之后,修改应用状态库202以记录应用服务304和305的状态为“未启动”。进一步地,请求处理装置203在获知容器40处于“已启动”状态之后,请求处理装置203通过容器引擎204检测到应用服务404已启动,对应用状态库202进行修改,修改应用状态库202以记录应用服务404的状态为“已启动”。
具体地,请求处理装置203通过容器引擎204发送应用服务状态查询指令至容器40,容器40在自身shell接口中输入“ps”命令以查询应用服务404的状态,并获知其为已启动,请求处理装置203通过容器引擎204获取应用服务404的状态为“已启动”。
修改后的应用状态库202如表3所示:
容器标识 应用服务标识 应用服务的状态(Status)
container1 apache 未启动(stop)
container1 ftp 未启动(stop)
container2 apache 已启动(run)
表3
通过以上步骤,可使得应用状态库202所记录的应用服务状态更新为与当前应用服务的状态一致,经更新的应用状态库202可用于以下步骤506-514。
在一种具体的场景中,请求处理装置203通过主机操作系统20的shell接口来执行“etcdctl set/myapp/container1/apache/status"stop"”命令,来修改位于“/myapp”存储路径中的应用状态库202,并将应用状态库202中在名为“container1”的容器30的,且名为“apache”的应用服务的状态记录为“stop”(即如表2第二行所示)。
并且,请求处理装置203通过主机操作系统20的shell接口来执行“etcdctl set/myapp/container1/ftp/status"stop"”命令,来修改位于“/myapp”存储路径中的应用状态库202,并将应用状态库202中在名为“container1”的容器30上的、名为“ftp”的应用服务的状态记录为“stop”(即如表2第二行所示)。
进一步,请求处理装置203通过主机操作系统20的shell接口来执行“etcdctl set/myapp/container2/apache/status"start"”命令,将应用状态库202中在名为“container2”的容器40上的、名为“apache”的应用服务的状态记录为“start”(即如表2第三行所示)。
其中,请求处理装置203在503部分获知容器30(container1)处于“未启动”状态,且容器40(container2)处于“已启动”状态时,通过查询应用状态库202即可获知container1中的所有应用服务的名称:apache和ftp,且container2中的所有应用服务的名称:apache。
在506部分,请求处理装置203接收到业务访问请求。该业务访问请求是由外部设备(如客户端)针对容器30中的应用服务304而发送的。
在主机100中,首先由图1中的物理网卡101接收业务访问请求,并经物理网卡驱动205解析发送至请求处理装置203。经解析后的业务访问请求可包括目的IP地址、目的端口、源IP地址、源端口以及请求类型,请求类型包括但不限于读请求、写请求、连 接请求、下载请求、测试请求等。其中,目的IP地址为主机100的外网IP地址,目的端口为应用服务304的主机端口,源IP地址和源端口为发出业务访问请求至主机100的终端的IP地址和端口。
在一个示例中,业务访问请求可为网页访问请求(http请求),请求类型为读请求,目的IP地址为123.456.78.101(主机100的外网IP地址),目的端口是12304(应用服务304的主机端口),源IP地址为123.456.98.102(外部设备的IP地址),源端口为8012。应用服务304可为Web服务器软件,如apache软件。
在另一个示例中,业务访问请求为下载请求(ftp请求)或其他常见的网络请求。
为了便于理解,在本实施例中,请求处理装置203的业务访问请求为网页访问请求。
在507和509部分,请求处理装置203在接收到业务访问请求后,解析到业务访问请求的目的端口为应用服务404的主机端口12304,查询路由表201中端口12304对应的容器地址192.168.1.3,根据容器地址192.168.1.3获知获知容器30的名称(如container1),在应用状态表202中查询容器container1的应用服务的状态,由于container1中的应用服务apache和ftp的状态均为“未启动”,因此可以确定容器30处于“未启动”状态(参见505部分),此时需要启动容器30,因此请求处理装置203存储业务访问请求,等待应用服务404启动后再转发业务访问请求。具体地,在507部分,请求处理装置203发送容器启动命令至容器引擎204。该容器启动命令为“docker start container1”,请求处理装置203通过主机操作系统20的shell接口来执行“docker start container1”命令。
值得注意的是,请求处理装置203会预先记录容器30的IP地址192.168.1.3与容器30的名称(如container1)之间的对应关系,由容器30的IP地址192.168.1.3获得容器30的名称container1。并且,请求处理装置203发送容器启动命令之后,可于508部分监控应用状态库202。该508部分可在发送容器启动命令之后或与发送容器启动命令同步执行。请求处理装置203可通过主机操作系统20的shell接口执行“confd/myapp”命令,来实现对应用状态库202的监控,“/myapp”为应用状态库202所在路径,应用状态库202存储在路径目录“/myapp”中。在一些实施例中,应用状态库的路径目录也可以是其他路径,本发明实施例对此不作限定。
在执行上述命令后,请求处理装置203可检测到应用状态库202的状态status变化。
在509部分,容器引擎204根据容器启动命令启动容器30。
值得注意的是,在本部分中,基于容器本身的轻量特性,容器30的启动速度为秒级。
在510部分,容器30启动应用服务304和305,并监控应用服务304和305是否完成启动。
其中,应用服务304和305可通过脚本设置为在容器30启动之后实现自动启动,图1中所示的应用服务监控模块303可用于监控应用服务304和305是否完成启动,应用服务监控模块303通过容器30的shell接口执行应用服务启动命令,应用服务启动命令例如可为“start”命令,其用法为“应用服务所在路径/bin/应用服务名称start”。
且应用服务监控模块303可进一步通过容器30的shell接口执行“curllocalhost:port/appname/index.html”命令,以监控应用服务304或305是否启动完成。其中localhost是指容器30本身,port为容器30为应用服务分配的端口(针对应用服务304是端口80,针对应用服务305是端口21),appname为应用服务名称(针对应用服务304是apache,针对应用服务305是ftp),该命令可用于监控容器30上的应用服务304或 305是否启动完成。
由于应用服务304为网页服务软件,需要进行连接数据库、读取配置文件等动作,因此其启动所需时间比容器30启动所需时间长。
在511部分,在容器30确认应用服务304和305启动完成后,将应用状态库202记录的应用服务304和305的状态更新为已启动。
具体地,容器30中的应用服务监控模块303通过向容器30的shell接口执行“etcdctlset/myapp/container1/apache/status"run"”命令,来修改位于“/myapp”目录中的应用状态库202,并将应用状态库202中“container1”对应的名为“apache”的应用服务304的状态修改为“run”(已启动)。
并且,应用服务监控模块303还通过向容器30的shell接口执行“etcdctl set/myapp/container1/ftp/status"run"”命令,将应用状态库202中“container1”对应的名为“ftp”的应用服务305的状态修改为“run”(已启动)。
在512部分,由于应用状态库202中应用服务304的状态被修改为已启动,该状态的改变会被请求处理装置203所检测到(参见步骤508),此时,请求处理装置203将业务访问请求转发至容器30。
值得注意的是,于此所述的“转发”是指:请求处理装置203根据业务访问请求所携带的目的端口12304,在路由表201中查找与该目的端口12304对应的容器30的IP地址和应用服务304的容器端口(192.168.1.3:80),将业务访问请求的目的IP地址123.456.78.101修改为容器30的IP地址192.168.1.3,将目的端口12304修改为应用服务304的容器端口80,并将更新后的业务访问请求发送至图1所示的网桥2041,网桥2041根据该业务访问请求所携带的容器30的IP地址192.168.1.3和应用服务304的容器端口80将该业务访问请求发送至容器30的虚拟网卡301的端口80,从而令应用服务304在该端口80接收到应用服务请求,进而对应用服务请求进行处理。
在513部分,请求处理装置203接收到针对设置在容器30内的应用服务304的另一业务访问请求,该另一业务访问请求可例如为另一Web网页访问请求。
在514部分,请求处理装置203在判断到另一业务访问请求的目的端口为应用服务404的主机端口12304,查询路由表201中端口12304对应的容器地址192.168.1.3,根据容器地址192.168.1.3获知获知容器30的名称(如container1),在应用状态表202中查询容器container1的应用服务的状态,由于container1中的应用服务apache和ftp的状态均为“已启动”(参见511部分),因此可以确定容器30处于“已启动”状态(参见505部分),此时不需要启动容器30,因此请求处理装置203不存储业务访问请求,直接将该另一业务访问请求转发至容器30,其中,转发规则可参考512部分所述,因此可使得应用服务304可对该另一业务访问请求进行处理。
可选地,请求处理装置203在转发另一业务访问请求之前,可查询应用状态库202中应用服务304的状态,具体地,在表2中container1的apache的status(状态)为“run(已启动)”时,可直接转发另一业务访问请求转发至容器30,若为“stop”则需要执行如507至511部分以启动容器30。
在本部分中,由于应用服务304已经启动,因此在接收到针对应用服务304的另一业务访问请求后,无需再次启动容器30,故不再重复执行507至511部分,而是将另一业务请求直接转发,可确保后续请求处理的速度。
在本实施例中,当请求处理装置接收到客户端的业务访问请求时,会判断处理该业务访问请求的应用服务是否已启动,只有在确定应用服务的状态为已启动时,才将业务访问请求转发至容器,避免容器在应用服务启动完成前接收到业务访问请求,无法对业务访问请求进行处理带来的访问失败的问题。
并且,在本实施例中,在初始状态下,当请求处理装置203接收到针对应用服务305的业务访问请求时,也会做出类似507至514部分的动作,从而保证业务访问请求不会因为容器40的启动速度过快而丢失。
进一步,当请求处理装置203接收到针对应用服务404的业务访问请求时,可根据应用状态库202中应用服务404的状态来转发应用服务304的业务访问请求。具体地,在查询到在表2中container2的apache的status(状态)为“run(已启动)”时,直接转发针对应用服务304的业务访问请求至容器40,由于跳过请求处理装置203的处理,因此可以保证请求处理速度。
以下请参见图3,图3示出请求处理装置203的内部结构。如图3所示,处理装置203包括接收模块101、容器启动模块102、应用状态库监控模块103以及发送模块104。
其中,接收模块101可执行上述部分506和513所述的功能,容器启动模块102可执行上述部分502和507所述的功能,应用状态库监控模块103可执行上述508部分所述的功能,发送模块104可执行上述512和514部分所述的功能。
上述的功能模块可通过脚本实现,脚本可在主机操作系统20的shell接口上运行,从而实现对应功能。
本发明实施例进一步提供一种主机,请参见图4,图4是根据本发明实施例的主机100的装置结构示意图,如图4所示,主主机100包括存储器602、处理器601和总线603,存储器602和处理器601分别与总线603连接,存储器602存储有程序指令以及应用状态库202,处理器601执行存储器602中的第一程序指令以实现请求处理装置203的功能,处理器601执行存储器602中的第二程序指令以实现应用服务监控模块303、403的功能,处理器601执行存储器602中的第一程序指令以执行步骤:接收客户端的业务访问请求,业务访问请求的目的端口为待访问的目的应用服务的主机端口;根据目的应用服务的主机端口,查询应用状态库202,当目的应用服务的状态为未启动时,存储业务访问请求,通过容器引擎启动目的应用服务所在的目的容器;处理器601执行存储器602中的第二程序指令以执行步骤:监控目的容器上的目的应用服务的状态,当目的应用服务启动完成时,在应用状态库202中记录应用服务的状态为已启动;处理器601执行存储器602中的第一程序指令以执行步骤:在监控到应用状态库202中记录的目的应用服务的状态为已启动时,将存储的业务访问请求转发给目的容器,以使得目的应用服务处理业务访问请求。
通过在确定应用服务的状态为已启动时,先存储业务访问请求,才将业务访问请求转发至容器,容器在于其中的应用服务在启动完毕之后才会接收到业务访问请求,使得应用服务可对业务访问请求进行处理,可保证业务访问请求不会因为容器的启动速度过快而丢失。
可选地,主机还包括路由表201,路由表201记录有应用服务的主机端口与应用服务的容器端口以及应用服务所在的容器的IP地址之间的对应关系。
可选地,处理器601执行存储器602中的第一程序指令以执行具体步骤来启动目的 容器:根据应用访问请求的目的端口,查询路由表201,确定目的应用服务所在的目的容器的IP地址,根据目的容器的IP地址通过容器引擎启动目的容器。
可选地,处理器601执行存储器602中的第一程序指令以执行具体步骤来转发业务访问请求:根据应用访问请求的目的端口,查询路由表201,将业务访问请求的目的IP地址修改为容器的IP地址,将业务访问请求的目的端口修改为应用服务的容器端口,将修改后的业务访问请求发送给目的容器。
可选地,处理器601执行存储器602中的第一程序指令以执行步骤:当目的应用服务的状态为已启动时,不存储业务访问请求,直接将业务访问请求发送给目的容器。
综上,图4所示的实施例详细介绍了主机的硬件架构,图4所示主机的功能和效果和图1及其对应内容完全一致,于此不作赘述。需说明的是,以上描述的任意装置实施例都仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本发明提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本发明可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本发明而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘,U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述的方法。
所属领域的技术人员可以清楚地了解到,上述描述的系统、装置或单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。

Claims (21)

  1. 一种主机,其特征在于,包括主机操作系统、请求处理装置、应用状态库以及容器,所述主机操作系统包括容器引擎,所述容器运行在所述容器引擎之上,所述容器包括应用服务和应用服务监控模块,所述应用状态库用于记录所述容器中运行的所述应用服务的状态,
    所述请求处理装置,用于接收客户端的业务访问请求,所述业务访问请求的目的端口为待访问的目的应用服务的主机端口;
    所述请求处理装置,还用于根据所述目的应用服务的主机端口,查询所述应用状态库,当所述目的应用服务的状态为未启动时,存储所述业务访问请求,通过所述容器引擎启动所述目的应用服务所在的目的容器;
    所述应用服务监控模块,用于监控所述目的容器上的所述目的应用服务的状态,当所述目的应用服务启动完成时,在所述应用状态库中记录所述应用服务的状态为已启动;
    所述请求处理装置,还用于在监控到所述应用状态库中记录的所述目的应用服务的状态为已启动时,将存储的所述业务访问请求转发给所述目的容器,以使得所述目的应用服务处理所述业务访问请求。
  2. 如权利要求1所述的主机,其特征在于,所述主机还包括路由表,所述路由表记录有所述应用服务的主机端口与所述应用服务的容器端口以及所述应用服务所在的容器的IP地址之间的对应关系。
  3. 如权利要求2所述的主机,其特征在于,
    所述请求处理装置,具体用于根据所述应用访问请求的目的端口,查询所述路由表,确定所述目的应用服务所在的目的容器的IP地址,根据所述目的容器的IP地址通过所述容器引擎启动所述目的容器。
  4. 如权利要求2-3任一所述的主机,其特征在于,
    所述请求处理装置,具体用于根据所述应用访问请求的目的端口,查询所述路由表,将所述业务访问请求的目的IP地址修改为所述容器的IP地址,将所述业务访问请求的目的端口修改为所述应用服务的容器端口,将修改后的业务访问请求发送给所述目的容器。
  5. 如权利要求1-4任一所述的主机,其特征在于,
    所述请求处理装置,还用于当所述目的应用服务的状态为已启动时,不存储所述业务访问请求,直接将所述业务访问请求发送给所述目的容器。
  6. 一种请求处理装置,其特征在于,设置于主机,包括:
    接收模块,用于接收客户端的业务访问请求,所述业务访问请求的目的端口为待访问的目的应用服务的主机端口;
    容器启动模块,用于根据所述目的应用服务的主机端口,查询所述应用状态库,当所述目的应用服务的状态为未启动时,存储所述业务访问请求,通过容器引擎启动所述目的应用服务所在的目的容器,其中,所述应用状态库用于记录所述主机上的容器中运行的应用服务的状态;
    应用状态库监控模块,用于监控所述应用状态库中记录的所述目的应用服务的状态;
    发送模块,用于在所述应用状态库监控模块监控到所述应用状态库中记录的所述目的应用服务的状态为已启动时,将所述容器启动模块存储的所述业务访问请求转发给所 述目的容器,以使得所述目的应用服务处理所述业务访问请求,其中,所述应用状态库中记录的所述目的应用服务的状态为所述目的容器的应用服务监控模块在所述目的应用服务启动完成后更新的。
  7. 如权利要求6所述的请求处理装置,其特征在于,所述主机还包括路由表,所述路由表记录有所述应用服务的主机端口与所述应用服务的容器端口以及所述应用服务所在的容器的IP地址之间的对应关系。
  8. 如权利要求7所述的请求处理装置,其特征在于,所述容器启动模块具体用于:
    根据所述应用访问请求的目的端口,查询所述路由表,确定所述目的应用服务所在的目的容器的IP地址,根据所述目的容器的IP地址通过所述容器引擎启动所述目的容器。
  9. 如权利要求7-8任一所述的请求处理装置,其特征在于,所述发送模块具体用于:
    根据所述应用访问请求的目的端口,查询所述路由表,将所述业务访问请求的目的IP地址修改为所述容器的IP地址,将所述业务访问请求的目的端口修改为所述应用服务的容器端口,将修改后的业务访问请求发送给所述目的容器。
  10. 如权利要求6-9任一所述的请求处理装置,其特征在于,
    所述容器启动模块,还用于在查询到所述目的应用服务的状态为已启动时,不存储所述业务访问请求;
    所述发送模块,还用于直接将所述业务访问请求发送给所述目的容器。
  11. 一种请求处理方法,其特征在于,所述方法应用于主机,所述主机包括主机操作系统、请求处理装置、应用状态库以及目的容器,所述主机操作系统包括容器引擎,所述目的容器运行在所述容器引擎之上,所述目的容器包括目的应用服务,所述方法包括:
    所述请求处理装置接收客户端的业务访问请求,所述业务访问请求的目的端口为待访问的目的应用服务的主机端口;
    所述请求处理装置根据所述目的应用服务的主机端口,查询所述应用状态库,当所述目的应用服务的状态为未启动时,存储所述业务访问请求,通过所述容器引擎启动所述目的应用服务所在的目的容器;
    所述目的容器监控所述目的容器上的所述目的应用服务的状态,当所述目的应用服务启动完成时,在所述应用状态库中记录所述应用服务的状态为已启动;
    所述请求处理装置在监控到所述应用状态库中记录的所述目的应用服务的状态为已启动时,将存储的所述业务访问请求转发给所述目的容器,以使得所述目的应用服务处理所述业务访问请求。
  12. 如权利要求11所述的方法,其特征在于,所述主机还包括路由表,所述路由表记录有所述应用服务的主机端口与所述应用服务的容器端口以及所述应用服务所在的容器的IP地址之间的对应关系。
  13. 如权利要求12所述的方法,其特征在于,所述请求处理装置通过所述容器引擎启动所述目的应用服务所在的目的容器具体包括:
    所述请求处理装置根据所述应用访问请求的目的端口,查询所述路由表,确定所述目的应用服务所在的目的容器的IP地址,根据所述目的容器的IP地址通过所述容器引擎启动所述目的容器。
  14. 如权利要求12-13任一所述的方法,其特征在于,所述请求处理装置将存储的所述业务访问请求转发给所述目的容器具体包括:
    所述请求处理装置根据所述应用访问请求的目的端口,查询所述路由表,将所述业务访问请求的目的IP地址修改为所述容器的IP地址,将所述业务访问请求的目的端口修改为所述应用服务的容器端口,将修改后的业务访问请求发送给所述目的容器。
  15. 如权利要求11-14任一所述的方法,其特征在于,还包括:
    当所述请求处理装置查询到所述目的应用服务的状态为已启动时,不存储所述业务访问请求,直接将所述业务访问请求发送给所述目的容器。
  16. 一种业务访问请求的处理方法,其特征在于,包括:
    接收客户端的业务访问请求,所述业务访问请求的目的端口为待访问的目的应用服务的主机端口;
    根据所述目的应用服务的主机端口,查询应用状态库,当所述目的应用服务的状态为未启动时,存储所述业务访问请求,通过容器引擎启动所述目的应用服务所在的目的容器,其中,所述应用状态库用于记录主机上的容器中运行的应用服务的状态;
    监控所述应用状态库,当所述应用状态库中记录的所述目的应用服务的状态为已启动时,将存储的所述业务访问请求转发给所述目的容器,以使得所述目的应用服务处理所述业务访问请求,其中,所述应用状态库中记录的所述目的应用服务的状态为所述目的容器的应用服务监控模块在所述目的应用服务启动完成后更新的。
  17. 如权利要求16所述的方法,其特征在于,所述主机还包括路由表,所述路由表记录有所述应用服务的主机端口与所述应用服务的容器端口以及所述应用服务所在的容器的IP地址之间的对应关系。
  18. 如权利要求17所述的方法,其特征在于,所述通过容器引擎启动所述目的应用服务所在的目的容器具体包括:
    根据所述应用访问请求的目的端口,查询所述路由表,确定所述目的应用服务所在的目的容器的IP地址,根据所述目的容器的IP地址通过所述容器引擎启动所述目的容器。
  19. 如权利要求17-18任一所述的方法,其特征在于,所述将存储的所述业务访问请求转发给所述目的容器具体包括:
    根据所述应用访问请求的目的端口,查询所述路由表,将所述业务访问请求的目的IP地址修改为所述容器的IP地址,将所述业务访问请求的目的端口修改为所述应用服务的容器端口,将修改后的业务访问请求发送给所述目的容器。
  20. 如权利要求16-19任一所述的方法,其特征在于,所述方法还包括:
    当所述目的应用服务的状态为已启动时,不存储所述业务访问请求,直接将所述业务访问请求发送给所述目的容器。
  21. 一种主机,其特征在于,包括存储器、处理器和总线,所述存储器和所述处理器分别与所述总线连接,所述存储器存储有程序指令以及应用状态库,所述处理器执行所述存储器中的第一程序指令以实现请求处理装置的功能,所述处理器执行所述存储器中的第二程序指令以实现应用服务监控模块的功能,
    所述处理器执行所述存储器中的第一程序指令以执行步骤:接收客户端的业务访问请求,所述业务访问请求的目的端口为待访问的目的应用服务的主机端口;根据所述目 的应用服务的主机端口,查询所述应用状态库,当所述目的应用服务的状态为未启动时,存储所述业务访问请求,通过所述容器引擎启动所述目的应用服务所在的目的容器;
    所述处理器执行所述存储器中的第二程序指令以执行步骤:监控所述目的容器上的所述目的应用服务的状态,当所述目的应用服务启动完成时,在所述应用状态库中记录所述应用服务的状态为已启动;
    所述处理器执行所述存储器中的第一程序指令以执行步骤:在监控到所述应用状态库中记录的所述目的应用服务的状态为已启动时,将存储的所述业务访问请求转发给所述目的容器,以使得所述目的应用服务处理所述业务访问请求。
PCT/CN2017/119108 2016-12-28 2017-12-27 业务访问请求的处理方法和相关设备 WO2018121625A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611239687.XA CN106817411B (zh) 2016-12-28 2016-12-28 业务访问请求的处理方法和相关设备
CN201611239687.X 2016-12-28

Publications (1)

Publication Number Publication Date
WO2018121625A1 true WO2018121625A1 (zh) 2018-07-05

Family

ID=59110506

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/119108 WO2018121625A1 (zh) 2016-12-28 2017-12-27 业务访问请求的处理方法和相关设备

Country Status (2)

Country Link
CN (1) CN106817411B (zh)
WO (1) WO2018121625A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634723A (zh) * 2018-12-20 2019-04-16 国网新疆电力有限公司信息通信公司 融合存载模块的通信方法及融合存载模块
CN111835684A (zh) * 2019-04-19 2020-10-27 厦门网宿有限公司 一种haproxy设备的网络隔离监控方法及系统
CN113783752A (zh) * 2021-08-26 2021-12-10 四川新网银行股份有限公司 一种内网跨网段间业务系统相互访问时网络质量监控方法
CN114095430A (zh) * 2021-10-14 2022-02-25 网宿科技股份有限公司 一种访问报文的处理方法、系统及工作节点

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106817411B (zh) * 2016-12-28 2020-06-02 华为技术有限公司 业务访问请求的处理方法和相关设备
CN107862480B (zh) * 2017-12-07 2021-12-28 泰康保险集团股份有限公司 业务管理方法、发布管理装置、介质及电子设备
CN108196940B (zh) * 2017-12-29 2022-03-11 华为云计算技术有限公司 删除容器的方法和相关设备
CN110633150A (zh) * 2019-09-12 2019-12-31 广东浪潮大数据研究有限公司 容器调度性能的测试方法及装置
CN114338133B (zh) * 2021-12-24 2023-07-07 中国联合网络通信集团有限公司 应用访问系统、方法、通信装置及存储介质
CN114726901B (zh) * 2022-05-23 2022-09-02 安徽华云安科技有限公司 容器访问方法、装置、设备和存储介质
CN115277586A (zh) * 2022-07-29 2022-11-01 中国电信股份有限公司 Pod流量处理方法、系统、设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103577257A (zh) * 2012-08-03 2014-02-12 杭州勒卡斯广告策划有限公司 一种rest服务方法、装置及系统
CN105512083A (zh) * 2015-11-30 2016-04-20 华为技术有限公司 基于yarn的资源管理方法、装置及系统
US20160330091A1 (en) * 2015-05-05 2016-11-10 Dell Products L.P. Software-defined-networking (sdn) enabling operating-system containers for real-time application traffic flow improvement
CN106130990A (zh) * 2016-06-29 2016-11-16 中国联合网络通信集团有限公司 容器访问的控制方法及装置
US20160342786A1 (en) * 2015-05-18 2016-11-24 Amir Gerebe Method and apparatus for applying application context security controls for software containers
CN106817411A (zh) * 2016-12-28 2017-06-09 华为技术有限公司 业务访问请求的处理方法和相关设备

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102857368B (zh) * 2012-07-11 2016-04-06 云络网络科技(上海)有限公司 一种服务器管理系统的分布式页面监控方法
CN104809045B (zh) * 2015-04-27 2021-01-05 腾讯科技(深圳)有限公司 监控脚本的运行方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103577257A (zh) * 2012-08-03 2014-02-12 杭州勒卡斯广告策划有限公司 一种rest服务方法、装置及系统
US20160330091A1 (en) * 2015-05-05 2016-11-10 Dell Products L.P. Software-defined-networking (sdn) enabling operating-system containers for real-time application traffic flow improvement
US20160342786A1 (en) * 2015-05-18 2016-11-24 Amir Gerebe Method and apparatus for applying application context security controls for software containers
CN105512083A (zh) * 2015-11-30 2016-04-20 华为技术有限公司 基于yarn的资源管理方法、装置及系统
CN106130990A (zh) * 2016-06-29 2016-11-16 中国联合网络通信集团有限公司 容器访问的控制方法及装置
CN106817411A (zh) * 2016-12-28 2017-06-09 华为技术有限公司 业务访问请求的处理方法和相关设备

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634723A (zh) * 2018-12-20 2019-04-16 国网新疆电力有限公司信息通信公司 融合存载模块的通信方法及融合存载模块
CN109634723B (zh) * 2018-12-20 2023-04-18 国网新疆电力有限公司信息通信公司 融合存载模块的通信方法及融合存载模块
CN111835684A (zh) * 2019-04-19 2020-10-27 厦门网宿有限公司 一种haproxy设备的网络隔离监控方法及系统
CN113783752A (zh) * 2021-08-26 2021-12-10 四川新网银行股份有限公司 一种内网跨网段间业务系统相互访问时网络质量监控方法
CN114095430A (zh) * 2021-10-14 2022-02-25 网宿科技股份有限公司 一种访问报文的处理方法、系统及工作节点
CN114095430B (zh) * 2021-10-14 2023-10-24 网宿科技股份有限公司 一种访问报文的处理方法、系统及工作节点

Also Published As

Publication number Publication date
CN106817411B (zh) 2020-06-02
CN106817411A (zh) 2017-06-09

Similar Documents

Publication Publication Date Title
WO2018121625A1 (zh) 业务访问请求的处理方法和相关设备
US11474829B2 (en) Customizing program logic for booting a system
US9880866B2 (en) Cryptographically attested resources for hosting virtual machines
US10466999B2 (en) Software hot upgrading method and device
US7631173B2 (en) Method and system for performing pre-boot operations from an external memory including memory address and geometry
US7925923B1 (en) Migrating a virtual machine in response to failure of an instruction to execute
US9104459B2 (en) Memory change tracking during migration of virtual machine (VM) with VM-controlled assigned peripherals
US8924965B2 (en) Memory state transfer of virtual machine-controlled peripherals during migrations of the virtual machine
US10146556B2 (en) System and method to perform an OS boot using service location protocol and launching OS using a dynamic update of network boot order without a reboot
JP6297715B2 (ja) コンピューティングデバイスの初期化トレース
WO2019237584A1 (zh) 容器的管理方法、装置、计算机设备及存储介质
US20120102135A1 (en) Seamless takeover of a stateful protocol session in a virtual machine environment
US20110314345A1 (en) Associating a monitoring manager with an executable service in a virtual machine migrated between physical machines
EP4100829A1 (en) Firmware update patch
US10860307B2 (en) Fragmented firmware storage system and method therefor
US9954958B2 (en) Shared resource management
CN109168328B (zh) 虚拟机迁移的方法、装置和虚拟化系统
US20140208089A1 (en) System and Method for Dynamically Changing System Behavior by Modifying Boot Configuration Data and Registry Entries
US20110239038A1 (en) Management apparatus, management method, and program
US11106380B2 (en) Migration of storage for workloads between desktop and cloud environments
CN109656679B (zh) 一种虚拟机的存储访问方法及装置
CN106815056B (zh) 基于jcl框架的应用热部署方法和装置
WO2020029995A1 (en) Application upgrading through sharing dependencies
CN111209078A (zh) 一种自动部署并检测虚拟机Web应用的方法及其系统
WO2021003729A1 (zh) 配置方法、物理设备、服务器及计算机可读存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17889474

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17889474

Country of ref document: EP

Kind code of ref document: A1