query network model

Recently, I looked at the code of the project and wrote the network model of the query.

The communication between cache and query is relatively simple, that is, tcp communication. The communication between qs and lq is through udp, and the scalability is relatively good. Record it here.

At the beginning, lq is bound to a port (udp can also be bound), and then qs reads the address of each lq through the configuration file, and then establishes a connection with no lq. When qs sends a request to lq, the request will contain a field, which is the address where qs is waiting to receive a reply, so that all lqs in the same group will send a reply to qs. qs receives the reply by means of epoll.

In fact, it is not complicated, but the method of including the reply address in the request simplifies the network model.

ps: Actually think about it, isn't the communication between cache and qs the same as the communication between qs and lq? Both are one-to-many processing, except that the tcp processing between cache and qs does not require artificial ack processing, so more links are processed and fewer operations (artificial acks). There are pros and cons in this comparison, but it was not clear why lq knew the address of the reply and looked at the code specifically.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326254878&siteId=291194637