title: How to improve Redis server's CPU usage?
body: <p>My goal is for our Redis server to hit about 80% CPU utilization in production. This will benefit our backend server design by ensuring we are not under-utilizing CPU while also leaving some headroom for growth and spikes.</p>
  
  <p>While using Redis' own benchmark tool <code>redis-benchmark</code>, it's very easy to reach about 100% CPU usage:</p>
  
  <pre><code>    $ redis-benchmark -h 192.168.1.6 -n 1000000 -c 50
  </code></pre>
  
  <p>On this benchmark, we assigned 50 clients to push 1,000,000 requests to our Redis server.</p>
  
  <p>But while using some other client tools(such as <a href="https://github.com/nrk/redis-lua" rel="nofollow noreferrer">redis-lua</a> or <a href="https://github.com/nicolasff/webdis" rel="nofollow noreferrer">webdis</a>), the maximum CPU usage is less than 60%.</p>
  
  <p>I browsed some code in <code>webdis</code> and <code>redis-lua</code>. <code>webdis</code> depends on <code>hiredis</code>, and <code>redis-lua</code> is implemented in Lua, and depends on socket(<code>lua-socket</code>).</p>
  
  <p>Are these clients too slow compared to the Redis benchmark and are unable to maximize the Redis CPU consumption?</p>
  
  <p>I also browsed some code in <code>redis-benchmark.c</code>. The benchmark's main work is done in <code>aeMain</code>. It seems like that the <code>redis-benchmark</code> uses fast code from Redis, and my test clients(<code>webdis</code> and <code>redis-lua</code>) do not.</p>
  
  <p>Currently my client have two choices:</p>
  
  <ol>
  <li>Use <code>redis-lua</code></li>
  <li>Use a tool like <code>webdis</code></li>
  </ol>
  
  <p>However, these two do not maximize Redis' CPU utilization (less than 60%). Are there any other choices?</p>
  
  <p>Or, is it possible to fully utilize redis-server outside of the <code>redis-benchmark</code> tool itself?</p>