memcached

memcached cluster maintenance

Scaling up memcached to a cluster of shards/partitions requires either distributed routing/partition table maintenance or centralized proxying (and other stuff like detecting failures). What are the popular/typical approaches/systems here? There's software like libketama, which provides consistent hashing, but this is just a client-side ...

PHP pecl/memcached extension slow when setting option for consistent hashing

Using the newer PHP pecl/memcached extension. Calls to Memcached::setOption() like; $m = new Memcached(); $m->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT); are costing between 150 to 500ms - just in making the call to setOption() and as we're not using persistent connections but rather doing this on every...

Storing cached data - what amount of formatting?

Hi everyone, I am in the middle of a web app and we're just about to start with a cache-layer that features memcache and disk-based cache. We just questioned ourself - what level/amount of formatting should we use on the stored cache data? Let say that we have a database table called articles. Articles table have a number of columns ...

Pros and cons with automated/manual cache

Hi everyone, I am thinking a lot about whether to head for a complete automated cache or manual cache. Our automatic approach would be a solution that digs through the database, queries and format each potential and future data request and saves it to an appropriate cache storage(memcache or disk based). Data would then not be invalida...

Using cassandra instead of memcache?

Hi! I keep reeding those articles from different sources that big sites are switching from memcache to cassandra. Coming from a mySQL background, I'll get a slight headache trying to see the pros/cons when compared to each other. Can you help me out to learn more about this? ...

How to replicate data with memcache

Hi everyone, I am trying to find good resources on best practices to data replication across memcache servers. What I want to accomplish is that if one of my servers in my pool goes down, the next server in line already has the info set. I have found "repcached" but since I run a WIN32 test environment, I have been unable to install it...

Super strange PHP error

Hi everyone, When trying memcache:get, I'll get the following error message back: Message: Memcache::get() [memcache.get]: Server localhost (tcp 11211) failed with: Failed reading line from stream (0) I run a Windows 32bit test environment (XP) and here's how my code looks: function getMulti(array $keys) { $items = $this->mem...

Is memcached a dinosaur in comparison to Redis?

Hi everyone, I have worked quite a bit with memcached the last weeks and just found out about Redis. When I read this part of their readme, I suddenly got a warm, cozy feeling in my stomach: Redis can be used as a memcached on steroids because is as fast as memcached but with a number of features more. Like memcached, Redis al...

ipTables blocking memcached

I have one server running memcached and another server that should be able to connect to the memcached server. memcached is set up to listen to 0.0.0.0:5666 This allows for anyone to connect to it so i want to block the port 5666 for everyone except the other server. I thought this would do it: iptables -A INPUT -p tcp --dport 5666 -j...

Memcached for PHP 5.3

Hi everyone, I have looked everywhere for some clues on how to run the Memcached extension in my WAMP windows development environment (thats right, the memcached with an D in the end, not memcache). I already use memcache (without the D), but it would be handy to take part of memcached's more extended multiple-server features. How can...

Rails: Using memcached on a horizontally partitioned DB

I am using a sharded db - horizontally partitioned. I am using the DataFabric gem from FiveRuns. What would be the implications of using memcached on this? Would it work the same as if I was using ActiveRecord? ...

Memcache failover and consistent hashing

Hi everyone, I am trying to work out a good way to handle offline/down memcached servers in my current web application that are built with PHP. I just found this link that shows an approach on how to do what I want, I think: http://cmunezero.com/2008/08/11/consistent-memcache-hashing-and-failover-with-php/ Anyhow, it gets me confused ...

PHP strange issue with memcache

Hi everyone, I am testing out some memcache code here in PHP: 1: $testInstance = new Memcache; $var = @$testInstance->connect('localhost', 11211); echo $var; // Outputs true no matter if the memcached is running or not. 2: $testInstance = new Memcache; $var = @$testInstance->connect('blablabla', 11211); echo $var; // Outputs false ...

Minimizing calls to database in rails

Hi guys, i am familiar with memcached and eager loading, but neither seems to solve the problem i am facing. My main performance lag comes from hundreds of data retrieval calls from the database. The tricky thing is that I do not know which set of users i need to retrieve until i have several steps of computation. I can refactor my c...

PHP callback function not being called

Hi everyone, I've got the following code: function failureCallback($host, $port) { print "memcache '$host:$port' failed"; } $this->memcache = new Memcache; ## bool Memcache::addServer ( string $host [, int $port = 11211 [, bool $persistent [, int $weight [, int $timeout [, int $retry_interval [, bool $status [, ca...

Approaches for memcached sessions

Hi everybody, I was thinking about using memcached to store sessions instead of mySQL, which seemed like a good idea, at first. When it comes to the failover part of utilizing memcached servers, It's a bit worrying that my sessions will stop working if the memcached would go offline. It will certainly affect my users. There's a few te...

PHP memcache - check if any server is available in pool?

Hi everyone, I have the following code: $cluster['local'] = array('host' => '192.168.1.1', 'port' => '11211', 'weight' => 50); $cluster['local2'] = array('host' => '192.168.1.2', 'port' => '11211', 'weight' => 50); $this->memcache = new Memcache; foreach ($this->cluster() as $cluster) { $this->memcache->addServer($cluster['host']...

Force memcached to write to all servers in pool

Hi everyone, I have thought a bit on how to make sure that a particular key is distributed to ALL memcached servers in a pool. My current, untested solution is to make another instance of memcached, something like this: $cluster[] = array('host' => '192.168.1.1', 'port' => '11211', 'weight' => 50); $this->tempMemcached = new Memcache...

Using Memcached in Python/Django - questions.

I am starting use Memcached to make my website faster. For constant data in my database I use this: from django.core.cache import cache cache_key = 'regions' regions = cache.get(cache_key) if result is None: """Not Found in Cache""" regions = Regions.objects.all() cache.set(cache_key, regions, 2592000) #(25...

Cache layer for MVC - Model or controller?

Hi everyone, I am having some second thoughts about where to implement the caching part. Where is the most appropriate place to implement it, you think? Inside every model, or in the controller? Approach 1 (psuedo-code): // mycontroller.php MyController extends Controller_class { function index () { $data = $this->model...