Step 4 - Challenge: Handling Concurrent Clients

In this step your goal is to handle multiple concurrent clients. If you haven’t already done so, now is the time to make your Redis server handle concurrent clients. You have two basic options here; have one thread per client or use the asynchronous programming support offered by your chosen programming language. If you have time, give both a go, both have pros and cons.

You can use redis-benchmark as a client to check how you handle concurrency:

% redis-benchmark -t SET,GET -q
SET: 108225.10 requests per second, p50=0.223 msec
GET: 115606.94 requests per second, p50=0.215 msec

Note that by default this will create 50 client connections to your server. Check the full documentation for Redis Benchmark to see how else you can use it.

You should move on to Step 5 when your server can handle the above command without crashing. If the command is taking too long to run add -n 1000 onto the end to reduce the number of requests. Play around with the number if needs be.

Don’t focus on performance, just check your server can handle concurrency without any errors.