This disclosure relates generally to the manner in which long poll requests are handled to reduce the number of redundant long polls created at a server.
In Internet Protocol (IP) interactions, servers receive requests from clients and respond to the open requests. This request-response perspective typically precludes a true push based interaction where the server can push information to the client when needed. Numerous interactions in which a server push would be desirable have arisen as real-time interactions have increased. Common needs for a push-based service include email delivery, chat sessions through a server, as well as other increasingly demanding fields including the delivery of content in Internet Protocol Television (IPTV) environment. In IPTV environments, a terminal (such as a set top box (STB)) may request updates to an electronic programming guide.
Instead of having the terminal poll the server at short intervals to determine if there is new content available a technique referred to as long polling has arisen. A long poll is a request issued by the client node that has a long expiry associated with it. When the server receives the request it will check to see if there has been any updates since the last response sent to the client (which may be done through the client providing an indication of the last response either as a timestamp of the last transmission or through the provision of a flag indicating the last time that the content was updated). If there has been no updated content since the last request, the server will hold off on replying until new content is available. Because there is an open request, the server is responding to the earlier request and not technically pushing content, though the experience to the user is effectively the same.
There are several known issues surrounding the use of long polling. One of the issues is that requests cannot be left open indefinitely. To address this, a timeout is typically associated with each long poll request. If no new content is available by the expiry of the timer, the server will respond. Typically to prevent unnecessarily sending redundant data, at the expiry of the long poll a server will respond with a NULL valued response. Upon receipt of a response, NULL valued or otherwise, the client will typically send another long poll request so as to allow the server to respond when new data becomes available.
The use of long polls put the responsibility on the server to maintain an open connection for each client that connects to it. It is possible that a client will have disconnected before the long poll is responded to. In such a case, the server will have unnecessarily consumed resources unless the client gracefully closed the session.
In many IP based connections, there are intermittent failures of the connection between the server and the client. Due to the nature of the TCP protocol suite as an idle protocol, an interrupted connection is considered to be active unless a node is otherwise aware or informed of the termination. This is done as a design choice as a failure at an intermediate node between the server and client may be resolved before either one is aware of the problem, in which case the connection will not need to be re-established. However if the failed connection is identified by a client with an open long poll, the recovery of the connection will often entail the client reconnecting to the server and issuing a new long poll. This will result in a redundant long poll open at the server until it is responded to with either new data or a NULL response.
Where there are a small number of clients connecting over reliable channels, the leakage of redundant long polls is manageable. However, in deployments with a large number of clients, where the clients may not have reliable connections, there can be a great deal of wasted resources on these redundant connections. Furthermore, in environments where the server is a node in a server cluster, reducing the number of redundant connections can result in reducing the need for additional servers. In a virtualized server environment, where the server functions are provided by a data center, reducing the resources consumed by redundant connections can reduce the cost of operating the virtualized server cluster. As such, there is a great deal of interest in reducing the number of redundant connections.
a illustrates an alternate solution, whereby a server in a cluster makes use of a client identifier (clientid) provided in the Long Poll Request to ensure that redundant connections are prevented. In step 64 a Long Poll Request with a client identifier is received. In step 66, the server determines whether a Long Poll associated with the clientid is already present on that server. If there is an existing long poll, the old connection is assumed to be redundant and is released in step 68, and a the new long poll is setup in step 70. If, in step 66, it is determined that the server doesn't have a long poll associated with the clientid, the clientid is broadcast to the other nodes in the server cluster in step 72 and the new long poll is setup in step 70. By carrying out this method, a server is able to ensure that it does not host redundant open long polls, and is able to notify the other servers in the cluster that there is a long poll being established that may make a long poll hosted by one of them redundant.
b illustrates a method carried out by servers in the same cluster as the server of
The combination of the methods of
Those skilled in the art will appreciate that preventing redundant long polls using a clientid is far easier in a single server environment. Accordingly, the use of a load balancer that ensures client stickiness to a particular server will reduce server-side complexity, but stickiness in client assignment can be counter productive to load balancing, and increases the complexity of the load balancing node.
One skilled in the art will appreciate that there is a need for a method of reducing the complexity of preventing redundant long poll connections in a clustered server environment so as to reduce the inter-server messaging while still preventing redundant connections.
Therefore, it would be desirable to provide a system and method that obviate or mitigate the above described problems
It is an object of the present invention to obviate or mitigate at least one disadvantage of the prior art.
In a first aspect of the present invention, there is provided, a method for handling redundant long poll requests from a client. The method is typically executed at a server and comprises the steps of identifying that a request received over a network interface is a request to establish a first long poll in a new session with the client; determining, in accordance with parameters of the received request, that a long poll from a previous session with the client could still be active; responsive to the determination, clearing any connection associated with the previous session with the client; and establishing the requested long poll in the new session.
In an embodiment of the first aspect of the present invention, the step of identifying includes determining that the received long poll request includes a last execution time, and optionally the step of determining that a long poll from a previous session could still be active includes determining that the difference between a current time and the last execution time is below a threshold which may be a long poll timeout value included in the received request. In another embodiment, the step of clearing any connection associated with the previous session includes clearing any connection for a long poll on the server associated with a client identifier included in the received request. In an alternate embodiment, the step of clearing any connection associated with the previous session includes transmitting a notification to peer servers in a cluster to clear any connection associated with a client identifier included in the received request, where this step is optionally performed upon determining that there are no local connections associated with the client identifier at the server. In another embodiment, the method further includes the steps of responding to the established long poll; receiving from the client a request to establish a subsequent long poll in the new session; and establishing the requested subsequent long poll in the new session. Optionally, the method can further include the step of determining that the received request is a request to establish a subsequent session by determining that the received request does not include a last execution time, where optionally the step of establishing the requested subsequent long poll is performed without an attempt to clear connections associated with a previous session in response to the determination that the received request does not include a last execution time.
In a second aspect of the present invention, there is provided a method for handling redundant long poll requests from a client. The method can be carried out at a first server in a cluster and comprises the steps of identifying that a request received over a network interface is a request to establish a long poll in an existing session between the client and the cluster, where a server in the cluster has replied to a previous long poll; and responsive to the identification, establishing the requested long poll without attempting to clear a connection associated with the client.
In an embodiment of the second aspect of the present invention, the step of identifying includes determining that the server in the cluster has replied by determining that the received request does not include a last execution time.
In a third aspect of the present invention, there is provided a method of issuing a long poll request. The method can be carried out by a client node in a network and comprises the steps of determining that a long poll request is the first long poll request in a session; and responsive to the determination, transmitting the long poll request with an indication of the last execution time of a long poll in a previous session.
In an embodiment of the third aspect of the present invention, the step of transmitting further includes including, in the long poll request, at least one of a client identifier and a long poll timeout. In a further embodiment of the present invention, the method can include the steps of receiving a reply to the requested long poll; and transmitting a subsequent long poll request without an indication of a last execution time of any previous long poll.
In a fourth aspect of the present invention, there is provided a server for handling the receipt of long poll request and the establishment of long poll requests. The server comprises a network interface, a data repository and a processor. The network interface receives the long poll request from a client. The data repository stores instructions. The processor, upon execution of the instructions stored in the data repository identifies that the received request is one of a request to establish a first long poll in a session and a request to establish a subsequent long poll in a session, establishes the requested long poll without attempting to clear a connection associated with the client in response to identifying that the received request is a request to establish a subsequent long poll, and establishes the requested long poll upon clearing any connection associated with a previous session with the client in response to identifying both that the received request is a request to establish a first long poll and that a long poll from a previous session with the client could still be active.
In an embodiment of the fourth aspect of the present invention, the data repository additionally stores data to associate a client identifier with an established open long poll request for use in clearing a connection in response to receipt of a long poll request from the client in a new session. In another embodiment, the processor clears the connection associated with a previous session by transmitting a client identifier to a peer server in a cluster using the network interface.
In a fifth aspect of the present invention, there is provided a node for issuing long poll requests to a server. The node comprises a network interface, a data repository and a processor. The network interface transmits requests to, and receives replies from, servers connected to a network. The data repository stores instructions. The processor, upon execution of the instructions stored in the data repository, determines that a long poll request is the first long poll request in a session; responsive to the determination, transmits a long poll request over the network interface, the transmitted long poll request including an indication of the last execution time of a long poll in a previous session; receives a reply the transmitted long poll request over the network interface; and transmits a subsequent long poll request without an indication of a last execution time of any previous long poll.
Other aspects and features of the present invention will become apparent to those ordinarily skilled in the art upon review of the following description of specific embodiments of the invention in conjunction with the accompanying figures.
Embodiments of the present invention will now be described, by way of example only, with reference to the attached Figures, wherein:
a is a flow chart illustrating a method of the prior art;
b is a flow chart illustrating a method of the prior art;
The present invention is directed to a system and method for establishing long poll handling.
The following discussion of methods and nodes should be understood to be of particular use in a managed environment. As an example, in an IPTV environment, the clients and servers can be assumed to behave in controlled and predictable manners. As an example, a client can be designed to interact in a particular manner, and the server method can be designed to anticipate such a behavior pattern. In such an environment, it should be understood that it may be possible to design a client that would take advantage of the server methods to reduce the efficiency of the server, but that the managed nature of the nodes reduces the likelihood of such behavior. It should further be understood that although one intended use is in a managed environment, the use of these method still provides advantages in an unmanaged environment as long as some client nodes behave in the proscribed manner.
Reference may be made below to specific elements, numbered in accordance with the attached figures. The discussion below should be taken to be exemplary in nature, and not as limiting of the scope of the present invention. The scope of the present invention is defined in the claims, and should not be considered as limited by the implementation details described below, which as one skilled in the art will appreciate, can be modified by replacing elements with equivalent functional elements.
Discussions will first be directed to the behavior and methods of a client of the present invention. The following discussion will be provided in the context of a client being a terminal in an IPTV environment, and the server being a content provider, such as the provider of Electronic Programming Guide (EPG) content. Those skilled in the art will appreciate that these are exemplary roles and should not be considered to be restrictive.
The combination of the clientid and the last execution time will be used at the server to determine if there is a redundant open long poll. By including an indication that this is not the first LP of the session (the indication may be an explicit indicator or even the absence of either of the clientid or the last_execution_time), the client is providing the server and indication that there was a previous Long Poll issued in the session, and that it was responded to, which allows the server to determine that this request will not make a previous long poll redundant, as the previous long poll has been closed and the resourced dedicated towards it have been released.
If it is determined that the received long poll request is the first long poll of a session, it is possible that a previous connection to the client has failed. At this point, the server examines, in step 128, information provided in the request to determine if it can be established that any previous polls have expired. If, based on the parameters provided with the long poll, it is determined that any polls from a previous session have expired (e.g. the previous session was ended when a user turned off a STB at night and the new session has begun the following evening, and any previous long poll request would have timed out), the method continues to step 126 as before. If it cannot be determined that any possible previous long polls have expired, the server will invoke a procedure in step 130 to clear any connections in the cluster associated with the client who issued the long poll request. Upon invoking this procedure, the server can proceed to setup the long poll in step 126 as before.
If it has been determined that there may be open long polls associate with the client sending the request received in step 120 of
Upon the negative evaluation of step 128, in step 130, the server determines if it has an open poll associated with the clientid of the received request in step 66. If there is an open poll at the server for the clientid, the old connection is closed in step 68. If such a poll exists on the server, it can be assumed that no other server in the cluster will have a redundant poll, and the process can continue on to step 68 in which the server will close the open poll. If there is no open poll at the server for the clientid, the server will broadcast the clientid to the other servers in the clusters in step 70. Because there is a possibility for an open poll at another server due to the keep_alive_timeout window, and the server having no indication that there cannot be a poll on another server, the broadcast can be justified as a consumption of bandwidth. One skilled in the art will appreciate that each server in the cluster can implement a method such as that illustrated in
One skilled in the art will appreciate that step 130 could be implemented as the execution of steps 70 and 68 (in either order or in parallel) without the decision of step 66. Upon completion of the steps 68 and 72, the process would then continue to step 126. The use of decision step 66 allow for a reduction in the amount of traffic generated between nodes in the cluster, which will be understood by those skilled in the art as being advantageous.
In step 154, server1202 determines that sufficient time has elapsed since the establishment of the long poll concluding step 108, that the keep_alive_timeout 154 has expired. Server1202 will then issue a long poll response with a null value, LPR <NULL> 156. At this point, client 200 can issue a new LP that will be routed to a server and handled as described above.
One skilled in the art will appreciate that where a client has never issued a long poll request before (e.g. when the client is brand new), there may not be a value for the last_execution_time. In such a case, the client may issue a request with a NULL value for the last_execution_time, as it would not be possible for such a client to be creating a redundant long poll request.
When used as a server such as server1202, node 250 additionally stores, in data repository 256, a mapping between open long poll connections and the clientid with which they are associated. This allows node 250 to determine (either during redundancy check 108 or in response to receipt of a clientid as a result of step 130 being carried out on another node in the server cluster) whether there are open polls associated with a particular clientid.
Node 250 may be implemented on conventional hardware including general purpose computing platforms, or on more specialized hardware designed for a particular purpose. It should be understood that the processor 254 and data repository 256 can be used for other purposes outside of the present invention as well.
Embodiments of the invention may be represented as a software product stored in a machine-readable medium (also referred to as a computer-readable medium, a processor-readable medium, or a computer usable medium having a computer readable program code embodied therein). The machine-readable medium may be any suitable tangible medium including a magnetic, optical, or electrical storage medium including a diskette, compact disk read only memory (CD-ROM), digital versatile disc read only memory (DVD-ROM) memory device (volatile or non-volatile), or similar storage mechanism. The machine-readable medium may contain various sets of instructions, code sequences, configuration information, or other data, which, when executed, cause a processor to perform steps in a method according to an embodiment of the invention. Those of ordinary skill in the art will appreciate that other instructions and operations necessary to implement the described invention may also be stored on the machine-readable medium. Software running from the machine-readable medium may interface with circuitry to perform the described tasks.
The above-described embodiments of the present invention are intended to be examples only. Alterations, modifications and variations may be effected to the particular embodiments by those of skill in the art without departing from the scope of the invention, which is defined solely by the claims appended hereto.