cess is explained in Figure 8-5. This method can eliminate collision; however, it is expensive to query the database to checkif a shortURL exists for every request. A technique called bloom filters [2] can improveperformance. A bloom filter i s a space-efficient probabilisti show annotation

n is long polling (Figure 12-4). In long polling, a client holds the connection open until there are actually new messagesavailable or a timeout threshold has been reached. Once the client receives new messages, itimmediately sends another request to the server, restarting the process. Long polling has afew drawbacks :• Sender and receiver may not c show annotation

ng polling has afew drawbacks:• Sender and receiver may not connect to the same chat server. HTTP based servers areusually stateless. If you use round robin for load balancing, the server that receives themessage might not have a long-polling connection with the client who receives themessage .• A server has no good way to t show annotation

Figure 12-5 shows how it works. WebSocket connection is initiated by the client. It is bi-directional and persistent. It starts itslife as a HTTP connection and could be “upgraded” via some well-defined handshake to aWebSocket connection. Through this persistent connection, a server could send updates to aclient. WebSocket connections generally work even if a firewall is in place. This is becausethey use port 80 or 443 which are also used by HTTP/HTTPS connections. Earlier we said that on the send show annotation

both sender and receiver sides. By using WebSocket for both sending and receiving, it simplifies the design and makesimplementation on both client and server more straightforward. Since WebSocketconnections are persistent, efficient connection management is critical on the server-side. High-level designJust now we men show annotation

In terms of computational expense, WebSocket itself is not particularly computationally expensive. Once the initial connection is established, WebSocket maintains an open connection, allowing for efficient bi-directional communication with minimal overhead. The protocol itself is designed to be lightweight and optimized for performance.

However, the computational expense of using WebSocket can depend on various factors:

Server Load: WebSocket connections require server resources to maintain open connections and handle incoming and outgoing messages. As the number of concurrent WebSocket connections increases, it can put a strain on server resources such as CPU and memory.

web_socket

ned criteria.Figure 12-11 shows how service discovery (Zookeeper) works. 1. User A tries to log in to the show annotation