Memcached and ttserver in PHP

Source: Internet
Author: User
Tags apc
In PHP, Memcached and ttserver used to use memcached for anti-brush control. recently I read some blog articles and some company projects to learn more about it and take notes .? PHP provides memcache and memcached. for their differences, we recommend that you refer to the PHP module: Memcached & gt; Memcache .? What is Memcached? Memcached and ttserver In Mem PHP

Previously, I only used memcached for anti-brush control. recently I read some blog articles and some company projects to learn more about it and take notes.

?

PHP provides memcache and memcached. for their differences, we suggest you read the PHP module: Memcached> Memcache.

?

What is Memcached?
Memcached is a high-performance distributed memory cache server developed by the development team of LiveJournal, a foreign community website. The general purpose is to reduce the number of database accesses by caching database query results, so as to speed up dynamic Web applications and improve scalability.

?

?

We know that memcached in PHP hasMemcached: addServers ()Add to server poolServersThe server specified by the parameter. When the Memcache Client uses the addServer server pool, the key is hashed to different servers based on the "crc32 (key) % current_server_num" hash algorithm, PHP, C, and python clients use such algorithms. The addserver of the Memcache Client has a failover mechanism. when addserver has two Memcached servers and one of them is down, current_server_num will change from 2 to 1.

?

Now let's test the distributed architecture. you may say that I don't have so many machines. you can referDistributed Application of memcached,

?

?

PHP and Memcache enable one or more processes on one or more machines in a distributed manner. Here, two processes are enabled on one machine and two ports are used: #/usr/local/bin/memcached-p 11211-d-u nobody #/usr/local/bin/memcached-p 11212-d-u nobodyPHP test code
 AddServer ("localhost", 11211); $ mem-> addServer ("localhost", 11212); $ mem-> add ('key1', 1 ); $ mem-> add ('key2', 2); $ mem-> add ('key3', 3); $ mem-> add ('key4', 4 );
?

Then let's look at memcache. php in memcache pecl to see the distribution of write values, so you can see the clues. (Apc. php is also used in prc. I didn't know I wanted to write one myself)

?

?

For more information about ttserver, see

?

?

Tokyocabinet/Tokyotyrant

Any Memcached client can directly call tokyotyrant.

?

Here I am lost. we often say that memcached is implemented by memcached.org. Tokyo Tyrant and Tokyo Cabinet constitute a distributed persistent storage system that supports high concurrency, for any original Memcached client, you can regard Tokyo Tyrant as a Memcached, but its data can be stored permanently. This is similar to the Memcachedb of Sina. Here, ttserver supports the memcached protocol. I only need to start ttserver to use memcache in php (you only need to start ttserver, instead of starting memcache). This is my vulgar understanding.

?

?

For more information, see http://www.google.com/cse/home? Cx = 016088334967758658265: ej58ey2f_s0 this custom google engine article on memcache. Some others translate documents.

?

Prepare to write a monitor for ttserver similar to apc. php...

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.