I’ve made a simple benchmark code for redis as below pseudocode.
for 10~100 redis sessions:
for n time:
key = some_random_string(key_size) # about 100 byte
data = some_random_string(data_size) # about 100k~1m
session.command("SET %s %s", key, data)
session.command("GET %s", key)
session.command("DEL %s", key)
When a benchmark program starts, memory usage of the redis-server process is monotonically increasing until it hits physical memory bound (8gb) and is released on session end. Since the concurrent number of key is limited to the session count, the peak size of data set shouldn’t be that large.
Is this intentional behavior by design? Or Did I misuse it?
Supposing the biggest value is 1 MB, you should have at most 3 MB per connection: 1 for the input buffer (SET), 1 for the value stored in Redis, 1 for the output buffer (GET). Input and output buffers are attached to the connections. You can check the client_biggest_input_buf as returned by the INFO command.
Note: Redis is not really designed to store large string objects.
That said, with a short C program, Redis 2.5.11, and 270 connections, I cannot reproduce the behavior you described.
Are you sure you do not have a MONITOR command running at the same time, a SLOWLOG configuration which results in Redis accumulating all your traffic, or a slave instance whose network link cannot cope with the traffic?