Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What can the request / response pattern in Redis do?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "what the request / response pattern in Redis can do". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

On the same connection, the request / response pattern is as follows:

Direction of interaction: the client sends request data and the server sends response data

Correspondence: each request data has and only one corresponding response data

Timing: the transmission of response data occurs after "the server fully receives its corresponding request data"

Serialization implementation

Serialization implementation, that is, on the same connection, the client receives the response of the first request and then initiates the second request.

Low throughput per second of the same connection:

Single connection throughput = 1 / (2 * network delay + time for server to process single request + time for client to process single request)

Redis has a very short processing time for a single request, so in serialization mode, a single connection spends most of its time waiting on the network and has the ability to make full use of the server.

Pipeline

The pattern for sending the next request without waiting for the last result to return becomes pipeline.

The TCP protocol that Redis depends on is full-duplex, and request / response interlacing does not cause confusion of request and response data, so the request data can be sent to the server in batches, and then each response data can be read in turn from the byte stream of server connections, which can greatly improve the throughput of a single connection.

This mode is suitable for batch independent write operations.

The implementation of pipeline depends on the client, and the following aspects need to be considered:

This is achieved through batch request sending or asynchronized request sending.

The amount of data in each batch needs to be considered under non-asynchronous batch transmission to avoid deadlock when the connected buffer is full.

How to encapsulate the interface to make it easy to use pipeline

The maximum throughput per second of a single connection that pipeline can achieve is:

(n-2 * network delay) / (n * (server single request processing time + client single request processing time))

When n is infinite, the network latency is negligible and the throughput is:

1 / (server single request processing time + client single request processing time)

That's all for "what the request / response pattern in Redis can do". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report