Let redis use tcmalloc to implement a high-performance nosql server's blog
Enables redis to use tcmalloc to implement high-performance nosql servers
By Elton on VII. 28,201 1, under C/C ++, Linux, nosql
Tcmalloc (thread-caching malloc) is a member of Google-perftools, an open-source tool developed by Google. Compared with the standard glibc library's malloc, tcmalloc has much higher efficiency and speed in memory allocation, which can greatly improve the performance of the MySQL server in high concurrency, reduce system load.
Installation Steps of the tcmalloc Library (in Linux ):
Step 1. Install the libunwind Library first for the 64-bit Operating System(Do not install the 32-bit operating system)
The libunwind library is based on 64-bit CPU and Operating SystemProgramProvides the basic stack trigger and undo functions, including the APIs used to output stack traces, APIs used to program the trigger and undo stacks, and APIs that support the C ++ exception handling mechanism.
123456 |
Wget HTTP: // Download.savannah.gnu.org / Releases/ Libunwind / Libunwind- 0.99 -Alpha.tar.gz Tar Zxvf libunwind- 0.99 -Alpha.tar.gz CD Libunwind- 0.99 -Alpha / Cflags =-FPIC. / Configure Make Cflags =-FPIC Make Cflags =-FPIC Install |
Step 2. Install Google-perftools:
12345678 |
Wget HTTP: // Google-perftools.googlecode.com / Files / Google-perftools-1.8.1.tar.gz Tar Zxvf google-perftools-1.8.1.tar.gzCD Google-perftools-1.8.1 / . / Configure -- Disable-CPU-Profiler -- Disable-heap-Profiler -- Disable-heap-checker -- Disable-debugalloc -- Enable-Minimal Make && Make Install Sudo Echo "/Usr/local/lib" > / Etc / LD. So. conf. d / Usr_local_lib.conf # If this file is not available, create one by yourself Sudo / Sbin / Ldconfig |
Step 3. Install redis
12345 |
$ curl -O HTTP: / redis.googlecode.com / files / redis-2.2.12.tar.gz $ tar xzvf redis-2.2.12.tar.gz $ Cd redis-2.2.12 $ make use_tcmalloc = Yes $ sudo make install |
Step 4. Check whether tcmalloc takes effect
12 |
sudo lsof -n | grep tcmallocredis-Ser 31590 Elton mem Reg 8 , 3 1155539 4856411 / USR / Local / lib / libtcmalloc_minimal.so.0.2.1 |
Step 5. Test redis
123456789101112 |
# modify the configuration file: Vim redis. conf # locate daemonize and change no to yes, run # then start redis: $. / redis-server. / redis. conf # connect to the database for testing $ SRC / redis-cliredis > set Foo barokredis > Get Foo " bar " |