1). Field of the Invention
This invention relates generally to a machine and to a method of operating a machine, more specifically to a machine and its method of use for providing responses to requests, and more specifically to a platform that can receive language independent processing code, deploy the code while processing requests online, execute multiple commands and join their answers, and scale automatically depending on load.
2). Discussion of Related Art
Computer systems are often used to provide responses to requests. A router receives the requests. The router then passes the requests to a service worker that determines an answer based on the request. The service worker then provides the answer to the router and router provides an output of the answer.
Commands are usually hard coded within such a system. As such, the system can only receive certain types of requests and provide certain types of answers. A search engine, for example, can only receive queries and provide results based on the queries. Such a system is thus not configurable to process different types of requests and provide different types of answers.
A load on a core of such a system can fluctuate depending on processing demand, in particular the number of requests and answers that are being processed. When the processing load becomes too high, it may not be possible for such a system to provide timely responses or answers to requests. Low volume traffic, on the other hand, will leave many system resources active, but unused.
A question and answer system usually has a single response. Because of the singular response, it is not possible to wait for answers based on multiple commands and then join the answers.
The invention provides a computer system including a router receiving a plurality of requests, a broker and a plurality of service workers, each assigned by the broker receive to receive the request and determining an answer based on the request, the router receiving the answers from the service workers, and the router providing an output that is based on at least one of the answers.
The computer system may further include a service pack store and a service pack stored in the service pack store, the service pack including at least one route and at least one worker, the broker deploying the service pack by distributing the at least one service worker to multiple locations to form the plurality of service workers, each at a respective one of the locations, and storing the routes within at least one router, wherein the request is distributed according to a command sequence based on the routes to the service workers at the multiple locations.
The router may further include a route registry responsible that matches uniform resource locator (URL) patterns from service pack routes to commands and plans a parallel execution plan for all commands.
The router may further include a router logic forming a primary run time loop managing the execution of the command sequence defined by a service pack and matched to a registry plan and manages synchronous and asynchronous flows of execution defined by a command chain.
The router may further include router context, namely shared context object responsible for aggregating all service responses from command chains of a route.
The router may further include a gateway, which is an interface for all commands to their respective service workers and commands, a command being a service code abstraction responsible for defining a processing service via router gateway calls.
The router may further include a broker detector which listens for router traffic broadcast by brokers, inspects broker indexes to determine what brokers are hosting which services and removes dead brokers when brokers stop broadcasting.
The router may further include a service pack loader that deploys new or updated service pack packages as they are discovered.
The router may further include a router service logger that distributes logging requests to the brokers for logging to a log store.
The router may further include a service cache that maintains a route specific cache for all requests and their responses.
The broker may further include a service monitor that manages active instance counts for all service workers deployed to a node.
The broker may further include a statistics monitor that inspects all processes and logs all service statistics.
The broker may further include a cluster executor that predicts the necessary number of service workers needed to maximize throughput and minimize request time and distributes real time command and control signals to a cluster of service workers clusters.
The broker may further include a service logger that intercepts logging messages from workers attached to the broker and writes them to the log store.
The broker may further include a message broker using socket handles registers workers and maintains heartbeat messaging with all known workers, and forwards traffic from router sockets to worker sockets using an availability queue.
The broker may further include a peer broker that uses user diagram protocol (UDP) broadcasts and listeners to create a broker to broker socket connection.
The broker may further include a service broadcaster using UDP broadcast messages to announce a presence of a broker on the network.
The broker may further include a service index using transmission control protocol (TCP) sockets to provide broker status including number and type of workers active, machine load, and message counts.
The broker may further include a service pack server using TCP sockets to stream service pack routing code from actively deployed services.
The service pack may be deployed while service workers other than the service workers that are being deployed determine answers based on requests.
The broker may spit the service pack into a routing package and a processing package, install dependencies for the processing package without interrupting processing of the requests, the processing package reporting that the processing package is ready for traffic, the broker further installing dependencies for the routing package without interrupting processing of the requests, the routing package listening for processing packages that report ready for traffic, detecting a processing package that report ready for traffic, and routing, in response to detecting the processing package reporting ready for traffic, traffic matching routes defined by service processors of the routing package.
The broker may validate the service pack before splitting of the service pack, validates the routing package after the service pack is split, and validates the processing package after the service pack is split.
The answers may be answers from service workers respectively receiving first and second commands forming part of at least a first command chain, the router waiting for the answer based on the second command after receiving the answer based on the first command, detecting the answer based on the second command, and joining the answers based on the first and second commands in answer to detecting the answer based on the second command.
The service workers may receive a third command forming part of the first command chain, the router waiting for the answer based on the third command after receiving the answer based on the second command, detecting the answer based on the third command, and joining the answers based on the first, second and third commands in answer to detecting the answer based on the third command.
The answers may be answers from service workers respectively receiving first and second commands forming part of at least a second command chain that is executed after the answers are joined, the router waiting for the answer based on the second command of the second command chain after receiving the answer based on the first command of the second command chain, detecting the answer based on the second command, and joining the answers based on the first and second commands of the second command chain in answer to detecting the answer based on the second command of the second command chain.
The answers may be answers from first and second service workers, the broker determining a load due to the plurality of requests, calculating an optimal load, and adjusting a number of service workers, the number being adjusted based on the optimal load.
The determination of the load may include recording statistics of processing of the requests, determining a distributed node status from a distributed node status store and collecting cluster resources based on the statistics and distributed node status, wherein the calculation of the optimal load may include calculating an optimal cluster layout based on the cluster resources and updating a distributed configuration store with new instance counts for services based on the optimal cluster layout, the number of service workers being adjusted based on the new instance counts for services.
The invention also provides a computer-based method of processing data, including receiving, by a computing device, a plurality of requests, distributing, by the computing device, each request to a plurality of service workers, determining, by the computing device, a plurality of answers, each answer being determined by the service worker based on the request, receiving, by the computing device, the answers from the service workers and providing, by the computing device, an output that that is based on at least one of the answers.
The computer-based method may further include storing, by the computing device, a service pack in a service pack store, the service pack including at least one route and at least one worker, deploying, by the computing device, the service pack by distributing the at least one service worker to multiple locations to form the plurality of service workers, each at a respective one of the locations and storing the routes within at least one router, wherein the request is distributed based on the routes to the service workers at the multiple locations.
The invention is further described by way of example with reference to the accompanying drawings, wherein:
The routers 12 are connected to a virtual internet protocol (IP) 28. In use, the routers 12 receive a plurality of requests from the virtual IP 28. The brokers 14 have socket connections 30 that are connected to socket connection pools 32 of the routers 12. The routers 12 distribute the requests to the brokers 14 via the socket connection pools 32 and socket connections 30.
Each broker 14 has a plurality of service workers 34. One or more of the service workers 34 associated with a broker 14 may receive the request from the broker 14. The service worker or workers 34 determine an answer based on the request. The broker 14 associated with the service worker or workers 34 that have determined an answer receives the answers from the service worker or workers 34. The broker 14 then provides the answer to the router 12. The router 12 includes user diagram protocol (UDP) listeners 36 that receive the answers back from the brokers 14.
The brokers 14 in
At 60, the new service pack is uploaded to the cluster. The new service pack is represented at 62. At 64, the new service pack is validated. At 66, the new service pack is flagged as active and is distributed to the service pack store 16. At 68, brokers 14 with excess capacity download the service pack 62. At 70, the brokers 14 validate the service pack 62. At 72, the brokers 14 split the service pack 62 into a routing package and a processing package.
At 74, the brokers 14 validate the processing package. At 76, the brokers 14 create a virtual environment for the processing package. At 78, the brokers 14 install dependencies for the processing package in a background thread. Active traffic is not interrupted. Such installation includes the distribution of the service workers 34 to multiple locations. At 80, the brokers 14 start the processing package in N processes as defined by an automatic scaling system. At 82, each processing package initializes. At 84, the respective processing packages each report “Ready for Traffic.”
At 86, the routers 12 download the routing packages from the connected brokers 14. At 88, the routers 12 validate the routing packages. At 90, the routers 12 install dependencies for routing code. At 92, the routers 12 install routing code. The routing code is installed via non-blocking operations that do not interrupt active traffic. At 94, the routers 12 include new routing logic in all the active routing threads. The new routing logic is included without restarting or interrupting active processes. The new routing logic adds the new routes defined by the service pack 62 to live routes. At 96, the routers 12 listen for processing packages that report “Ready for Traffic.”
When the router 12 at 98 detects a processing package that reports “Ready for Traffic,” the router proceeds at 100 to begin routing traffic based on routes defined within service processors defined in the routing package. The service processors define routing to selected ones of the routers 12 and service workers 34.
After the responses are joined at 122, the router 12 executes the second command chain 106. The second command chain 106 includes a plurality of commands 130 to 140 that process a request following the joining at 122. The router 12 again waits until answers are detected based on all the commands 130 to 140 and then, at 142 joins the answers based on the commands 130 to 140.
Similarly, the router 12, in response to joining the answers at 142 executes the third command chain 108. The third command chain 108 may have a plurality of commands 150 to 160. At 162 the router 12 joins the answers based on the commands 150 to 160.
The route 102 includes a response builder 164. The answers that are joined at 162 are provided to the response builder 164. The response builder 164 uses the joined answers to calculate and provide a response 166.
The service pack 50 shown in
1. A service pack contains only routing code. This code may call existing and external web services and aggregate their responses using the same .join( )/.does( ) logical chains. Or the service pack may only perform some transformation to the input given purely within the router.
2. A service pack may simply call service workers defined in other service packs via calls to the brokers hosting the services. This is made possible via the broker named service bus interface that routes messages to service workers over sockets via named entries in a service table maintained by each broker and advertised to each router.
Referring again to
At 200, broker report statistics are grouped by service worker. The statistics include load, computer processing unit (CPU) usage, memory usage, disk space usage and queries per second (QPS). At 202, similar statistics are stored for routers 12. A distributed node status store 204 includes data regarding the status of various nodes such as socket connections and UDP broadcasters and listeners. At 206, a periodic system balancer carries out rebalancing. At 208, a determination is made whether a balance has recently run. If no balance has recently run, then at 210, cluster resources are collected via a distributed statistics interface 212. The cluster resources include the broker report statistics, router report statistics and the statuses of the various nodes. In general, 202 to 212 comprise a determination of load due to requests 214.
At 214, an optimal load cluster layout is calculated based on the cluster resources collected at 210. A distributed configuration store 216 includes a configuration of an existing cluster layout for service workers, etc. At 218, the configuration within the distributed configuration store 216 is updated via a distributed configuration interface 220. The configuration is updated with new instance counts for all services. In general, 214 to 220 comprise a calculation of an optimal load 222. At 224, the configuration within the distributed configuration store 216 is used for service worker deployment, in particular for adding or removing service workers.
The exemplary computer system 900 includes a processor 930 (e.g., a central processing unit (CPU), a graphics processing unit (GPU), or both), a main memory 932 (e.g., read-only memory (ROM), flash memory, dynamic random access memory (DRAM) such as synchronous DRAM (SDRAM) or Rambus DRAM (RDRAM), etc.), and a static memory 934 (e.g., flash memory, static random access memory (SRAM, etc.), which communicate with each other via a bus 936.
The computer system 900 may further include a video display 938 (e.g., a liquid crystal display (LCD) or a cathode ray tube (CRT)). The computer system 900 also includes an alpha-numeric input device 940 (e.g., a keyboard), a cursor control device 942 (e.g., a mouse), a disk drive unit 944, a signal generation device 946 (e.g., a speaker), and a network interface device 948.
The disk drive unit 944 includes a machine-readable medium 950 on which is stored one or more sets of instructions 952 (e.g., software) embodying any one or more of the methodologies or functions described herein. The software may also reside, completely or at least partially, within the main memory 932 and/or within the processor 930 during execution thereof by the computer system 900, the memory 932 and the processor 930 also constituting machine readable media. The software may further be transmitted or received over a network 954 via the network interface device 948.
While the instructions 952 are shown in an exemplary embodiment to be on a single medium, the term “machine-readable medium” should be taken to understand a single medium or multiple media (e.g., a centralized or distributed database or data source and/or associated caches and servers) that store the one or more sets of instructions. The term “machine-readable medium” shall also be taken to include any medium that is capable of storing, encoding, or carrying a set of instructions for execution by the machine and that cause the machine to perform any one or more of the methodologies of the present invention. The term “machine-readable medium” shall accordingly be taken to include, but not be limited to, solid-state memories and optical and magnetic media.
While certain exemplary embodiments have been described and shown in the accompanying drawings, it is to be understood that such embodiments are merely illustrative and not restrictive of the current invention, and that this invention is not restricted to the specific constructions and arrangements shown and described since modifications may occur to those ordinarily skilled in the art.