PHP uses memcache long connections as a place to be aware of RPC clients

Source: Internet
Author: User
Tags failover

Memcache Extended Version 3.0.8

I. Retry_interval

$retry _interval The time of failover after an RPC server-side failure, the node is marked as unavailable, isolated, and quarantined for less than 0 retry_interval of time.

intMmc_server_valid (mmc_t *mmc tsrmls_dc)/*checks if a server should is considered valid to serve requests { {{*/{    if(MMC! =NULL) {        if(Mmc->tcp.status >=mmc_status_disconnected) {            return 1; }        if(Mmc->tcp.status = = mmc_status_failed &&MMC->tcp.retry_interval >=0&& (Long) Time (NULL) >= mmc->tcp.failed + mmc->tcp.retry_interval) {
This is compared to the current time and fault occurrence time + isolation timereturn 1; } } return 0;}

Two. Retry Policy

Requesting a node to time out or fail will have a chance to retry, but when the server restarts, it does not seem to be a retry, just mark the connection status as unavailable. When the connection is used for the second time, the connection is rebuilt, so how many connections are made before the restart, and how many requests are unavailable.

/*read more data from Socket*/if(Php_stream_eof (mmc->readreq->io->stream)) {//server-side active disconnect, stream reads EOF result= Mmc_server_failure (MMC, Mmc->readreq->io,"Read failed (socket was unexpectedly closed)",0tsrmls_cc); if(Result = =mmc_request_failure) {        /*Take server offline and failover requests*/mmc_server_deactivate (pool, MMC tsrmls_cc); }    if (result = = Mmc_request_retry) {mmc_select_retry (pool, MMC, mmc-> readreq tsrmls_cc); }} Break;

The Scarlet Letter is after I add, originally the extension although marked the result is mmc_request_retry, but did not do the retry. A simple method can also be used in the extension to New Memcache (), Addserver once.

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.