Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3793072
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:43:10+00:00 2026-05-19T12:43:10+00:00

hypothetically – if I have multiple memcached servers like this: //PHP $MEMCACHE_SERVERS = array(

  • 0

hypothetically – if I have multiple memcached servers like this:

//PHP 
$MEMCACHE_SERVERS = array(
    "10.1.1.1", //web1
    "10.1.1.2", //web2
    "10.1.1.3", //web3 
); 
$memcache = new Memcache();
foreach($MEMCACHE_SERVERS as $server){
    $memcache->addServer ( $server ); 
}

And then I set data like this:

$huge_data_for_frong_page = 'some data blah blah blah';
$memcache->set("huge_data_for_frong_page", $huge_data_for_frong_page);

And then I retrieve data like this:

$huge_data_for_frong_page = $memcache->get("huge_data_for_frong_page");

When i would to retrieve this data from memcached servers – how would php memcached client know which server to query for this data? Or is memcached client going to query all memcached servers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:43:11+00:00Added an answer on May 19, 2026 at 12:43 pm

    Well you could write books about that but the basic principle is that there are some different approaches.

    The most common and senseful approach for caching is sharding. Which means the data is stored only on one server and some method is used to determining which server this is. So it can be fetched from this very server and only one server is involved.

    This obviously works well in key/value environments as memcached.

    A common practice is to take a cryptographical hash of the key. Calculate this hash MOD number of servers and the result is the server you will store and fetch the data.

    This procedure produces more or less equal balancing.

    How it’s exactly done in memcached I don’t know. But some sort of hash for sure.

    But beware that this technique is not highly available. So if one server fails the entries are gone. So you obviously can only use this for caching purposes.

    Other techniques, where for example high availability of resources is necessary, that take long to calculate and are automatically warmed up in the background, involve replication.

    The most common form in caching environments is master-master replication with latest-timestamp conflict resolving. Which basically means every server gets the data from everyserver that is not yet on the local server (this is done using replication logs and byte offsets). If there is a conflict the latest version is used (the slight time offset between servers is ignored).

    But in other environments where for examply only very little is written but a lot is read there is often a cascade where only one or few master servers are involved and the rest is just pure read replication.

    But these setups are very rare because sharding as described above gives the best performance and in caching environments data loss is mostly tolerable. So it’s also default for memcached.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hypothetically, you have two products, one written in Java, the other in C#. You
I have two tables named foo and bar , hypothetically speaking. foo has columns
Hypothetically, in a SQL Server database, if I have a table with two int
Hypothetically, tets say someone tells you to to expect X (like 100,000 or something)
Hypothetically I have two tables Employee and Locations. Additionaly I have a view viewEmpLocation
Say hypothetically I have a class... class Main { $prop1 = 2; $prop2 =
I have a controller/model hypothetically named Pets. Pets has the following declarations: belongs_to :owner
Let's say hypothetically you have a two-level paging system with a 32-bit logical address
So, I have a template string with X amount of tokens in it. Hypothetically
With a piece of code like this, the compiler complains on c.MyProperty : MyClass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.