详情请看memcache的安装文件下的threads.txt文件

By default, memcached is compiled as a single-threaded application. This is
the most CPU-efficient mode of operation, and it is appropriate for memcached
instances running on single-processor servers or whose request volume is
low enough that available CPU power is not a bottleneck.

More heavily-used memcached instances can benefit from multithreaded mode.
To enable it, use the "--enable-threads" option to the configure script:

./configure --enable-threads

You must have the POSIX thread functions (pthread_*) on your system in order
to use memcached's multithreaded mode.

Once you have a thread-capable memcached executable, you can control the
number of threads using the "-t" option; the default is 4. On a machine
that's dedicated to memcached, you will typically want one thread per
processor core. Due to memcached's nonblocking architecture, there is no
real advantage to using more threads than the number of CPUs on the machine;
doing so will increase lock contention and is likely to degrade performance.

------------------

如上所说,我们的memcache服务器在编译安装的时候默认是单线程应用,如果你想变成支持多线程的,那么编译的时候指定./configure --enable-threads就可以编译成支撑多线程的应用程序了。主要是为了现在的多核系统准备的。

但是官方文档也明说了,你的机器必须支持多线程编程,否则还是用不了那个memcache的多线程模式

You must have the POSIX thread functions (pthread_*) on your system in order
to use memcached's multithreaded mode.

同时,默认的线程数是4,还特别声明,你的线程数如果超过你的cpu数量,增加了发生内容操作死锁的情况的概率。会严重影响缓存效果。

----总结说来,不会用多线程,或者机器不是那么牛,还是不要用啦,如果真有必要,你好好研究下官方的线程文件,别乱用导致更加严重的性能问题!

 备注:linux的编译时候的那些乱七八糟的命令,其实就和我们在windows下安装tomcat的时候是不是安装相关文档和程序一样

Logo

更多推荐