框架——緩存框架——redis——功能——管道

1、概念

  引用原著

Redis pipelining is a technique for improving performance by issuing multiple commands at once without waiting for the response to each individual command

Redis pipeline批量執行命令,一次性將結果返回,相較於多次執行命令,性能提升很多。

它與Linux命令使用管道的格式一樣,含義卻不同,Linux管道是將上一個命令的結果傳遞給下一個命令,而redis只是分割多個命令,這些命令的結果會一次性返回。

2、操作

 性能提升主要有兩方面。

第一點,rtt,全稱爲round trip time。

  Clients and Servers are connected via a network link. Such a link can be very fast (a loopback interface) or very slow (a connection established over the Internet with many hops between the two hosts). Whatever the network latency is, it takes time for the packets to travel from the client to the server, and back from the server to the client to carry the reply. This time is called RTT (Round Trip Time)

C/S模式下,client和server通常不在一臺機器上,所以要建立網絡連接,client要通過網絡傳輸將請求數據給server,server也要通過網絡將響應數據返回給server,整個消耗在網絡上的時間稱爲rtt。

第二點,syscall latency,系統執行時產生的延遲。系統批量執行一次,與系統執行多次的差別主要體現在:

用戶進程和內核進程之間的上下文切換,多次執行會導致多次切換。

訪問磁盤上的data,多次執行,會導致多次訪問,需要在磁盤和內存之間做多次I/O操作。

其他略。

總體而言,批量執行比多次執行快。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章