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

The performance Test of redis and the method of realizing client connection

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article will explain in detail the performance testing of redis and the method of realizing client connection. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Redis performance test

Grammar

Redis-benchmark [option] [option value]

Example

Example one

The following example executes 1000 requests simultaneously to test performance:

$redis-benchmark-n 1000-Q

Ps: local docker does not support commands for the time being. Skip the result, please test it yourself.

Redis:6379 > benchmark-n 1000-Q (error) ERR unknown command 'benchmark'

Example two

The host is 127.0.0.1, the port number is 6379, the command executed is set, lpush, and the number of requests is 1000. The result shows only the number of requests executed per second through the-Q parameter.

$redis-benchmark-h 127.0.0.1-p 6379-t set,lpush-n 1000-Q performance test parameters

Serial number option description default value 1MyH specify server hostname 127.0.0.12murp specify server port 63793murs specify server socket4-c specify number of concurrent connections 505-n specify number of requests 100006-d specify data size of SET/GET value in bytes 27-k1=keep alive 0=reconnect18-rSET/GET/INCR uses random key, SADD uses random value

9Murp forcibly exits redis through a pipeline transmission request 110Murq. Show only query/sec values

11-csv output in CSV format

12murl generates a loop that permanently executes the test

13murt only runs a comma-separated list of test commands.

14-IIdle mode. Open only N idle connections and wait.

Redis client connection

Redis receives connections from clients by listening on a TCP port or Unix socket. When a connection is established, the following operations will be performed within Redis:

First, the client socket is set to non-blocking mode because Redis uses a non-blocking multiplexing model for network event handling.

Then set the TCP_NODELAY property for the socket to disable the Nagle algorithm

Then create a readable file event to listen to the data sent by the client socket

Maximum number of connections

Redis:6379 > config get maxclients1) "maxclients" 2) "10000" instance

Set the maximum number of connections to 999 at startup

Redis-server-maxclients 999

Client command

S.N. Command description 1CLIENT LIST returns the list of clients connected to the redis service 2CLIENT SETNAME sets the name of the current connection 3CLIENT GETNAME gets the name of the service set by the CLIENT SETNAME command 4CLIENT PAUSE suspends the client connection, specifies the suspension time in milliseconds 5CLIENT KILL closes the client connection on the redis performance test and the method of realizing the client connection is shared here. I hope the above can be helpful to you and you can learn more knowledge. If you think the article is good, you can share it for more people to see.

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

Database

Wechat

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

12
Report