Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

php - Memcache : Confusions

I am going to use memcache(not memcacheD) for my PHP application . I have few confusions .

I found this wrapper class for memcache.

1)As on connect method it adds all servers to pull. If this is done on every single request wont it slow down the permanence cause of network latency ?

2)if there are 2 servers in a pool and one goes offline requests will still be made to offline server ? There is no other way to automatically remove offline server from memcache ? If not what does memcache.allow_failover = 1 setting do ?

3) IS there a way to see how many cache requests were served by which memcache server ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Any memcache API/wrapper will do. You can even build your own through PHP's CURL methods.

1) Does every single request pull all servers & cause network latency?

No. When your application makes a request, it attempts to connect to a single server, and "go-fish" to the next server on failure, NOT_FOUND, timeout, &tc. There may be some network latency, but a lot less then interacting with a database. If your concerned about I/O & latency, you should be able to architect a simple solution within your applications.

2) Will request still be made to offline server?

Up to you. Although the system is down, your application may still be trying to connect to it. If you decide to go with PECL's memcache API, your applications should be able to identify if memcached is operating normally on any given server. Memcache::checkServerStatus

2.1) What does memcache.allow_failover do?

This does exactly what it says. If you have memcached servers A, B, and D. And server A goes down. Both options will issue a USER_NOTICE; however, memcache.allow_failover=1 will continue to server B, and allow reads and writes. When memcache.allow_failover=0 all memcache I/O will return false gracefully.

Checkout the docs.

3) Memcached server reporting

Memcached offers a stats command, and PECL's memcache also gives a status method. However they're related to memory/slab statistics. If you would like a monitoring report of usage, Check out New Relic


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...