Redis is 10 times faster than memcached.

Source: Internet
Author: User
Tags benchmark keep alive

Reference a passage in a Chinese article in Python:
"Redis is a high-performance Key-value database. The emergence of redis largely compensated for the shortage of keyValue storage such as memcached,
It can complement relational databases in different scenarios. It provides python, Ruby, Erlang, and PHP clients for ease of use.
The problem is that this project is still quite new and may not be stable enough, and there are no actual instances for large-scale system applications.
In addition, the lack of batch get in MC is also a big problem. The network overhead of batch get is different from that of multiple get. "

Http://www.okpython.com/bbs/viewthread.php? Tid = 5085 & Highlight = redis

In a sense, memcached has done quite well in redis.
However, I learned from my colleagues that redis and redis have a good read/write speed and can back up data in memory to the disk at regular or irregular intervals.
It is truly safe and fast.
Next I will write my installation experiences and hope Jie zhanhui can help my friends who have just come into contact with redis.
Get redis first. I generally download python from China, where most mainstream Linux software is available.

Http://www.okpython.com/bbs/viewthread.php? Tid = 5086 & Highlight = redis

[Root @ localhost/] # cd/soft
[Root @ localhost soft] # tar zvxf redis-1.2.6.tar.gz
[Root @ localhost redis-1.2.6] # Make
# Copy two configuration files and command files to the following directory
CP redis. CONF/etc/redis/
CP redis-benchmark redis-cli redis-server/usr/bin/
2. modify some parameters
# Set Kernel Parameters
Echo 1>/proc/sys/Vm/overcommit_memory
# Modify/etc/redis. conf
Daemonize Yes
Logfile/dev/null # Log File Path

Start redis
[Root @ localhost redis-1.2.6] # redis-server/etc/redis. conf
New PID: 983

3. test whether the service is normal.
Redis-Benchmark

===== Set ======
10000 requests completed
In 0.24 seconds
50 parallel clients
3 bytes Payload
Keep alive: 1

1.15% <= 0 milliseconds
80.95% <= 1 milliseconds
99.66% <= 2 milliseconds
99.70% <= 3 milliseconds
99.73% <= 4 milliseconds
99.76% <= 5 milliseconds
99.78% <= 6 milliseconds
99.81% <= 7 milliseconds
99.83% <= 8 milliseconds
99.85% <= 9 milliseconds
99.87% <= 10 milliseconds
99.89% <= 11 milliseconds
99.91% <= 12 milliseconds
99.93% <= 13 milliseconds
99.95% <= 14 milliseconds
99.96% <= 15 milliseconds
99.98% <= 16 milliseconds
100.00% <= 17 milliseconds
40983.61 requests per second

===== Get =====
10001 requests completed
In 0.11 seconds
50 parallel clients
3 bytes Payload
Keep alive: 1

48.79% <= 0 milliseconds
99.50% <= 1 milliseconds
99.53% <= 2 milliseconds
99.60% <= 3 milliseconds
99.65% <= 4 milliseconds
99.69% <= 5 milliseconds
99.72% <= 6 milliseconds
99.75% <= 7 milliseconds
99.81% <= 8 milliseconds
99.86% <= 9 milliseconds
99.91% <= 10 milliseconds
99.96% <= 11 milliseconds
100.00% <= 12 milliseconds
90918.18 requests per second

Everything works properly
Test Based on command line:
[Root @ localhost redis-1.2.6] # redis-cli set spawn king
OK
[Root @ localhost redis-1.2.6] # redis-cli get Spawn
King
Download the redis-based PHP module:
[Root @ localhost redis-1.2.6] # CD ..
[Root @ localhost soft] # SVN checkout http://phpredis.googlecode.com/svn/trunk/
[Root @ localhost soft] # cd trunk/
[Root @ localhost trunk] #/usr/local/PHP/bin/phpize
Processing ing:
Php api version: 20041225
Zend module api no: 20060613
Zend extension api no: 220060519
Recompile PHP
[Root @ localhost trunk] #./configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config
[Root @ localhost trunk] # Make & make install
Installing shared extensions:/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/
Add extension_dir = redis. So to PhP. ini.
[Root @ localhost trunk] # vi/usr/local/lib/PHP. ini

Write a PHP test code: $ redis =
New redis ();
$ Redis-> connect ('2017. 0.0.1 ', 127 );
$ Redis-> set ('spawn ', 'King ');
Echo $ redis-> get ('spawn ');
// Result: King

Another PHP code implementation version can be found in the following file:

Http://code.google.com/p/redis/source/browse/#svn/trunk/client-libraries/php

But it does not seem easy to use.
The following are the methods provided on the official website, and no problems have been found.

Http://code.google.com/p/php5-redis/downloads/list

Performance test results:

Set operation 110000 times per second, get operation 81000 times per second
The efficiency is more than 10 times that of memcache.
Hope to understand the articles of zhanhui can help everyone, technical problems can communicate with me in a timely manner, jeffxie@gmail.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.