Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When not to use memcache

Tags:

php

memcached

Currently we are having a site which do a lot of api calls from our parent site for user details and other data. We are planning to cache all the details on our side. I am planning to use memcache for this. as this is a live site and so we are expecting heavier traffic in coming days(not that like FB but again my server is also not like them ;) ) so I need your opinion what issues we can face if we are going for memcache and cross opinions of yours why shouldn't we go for it. Any other alternative will also help.

like image 980
ankur.singh Avatar asked Jun 03 '11 20:06

ankur.singh


People also ask

When should you use memcached?

It is used for speeding up dynamic web applications by reducing database load. In other words, every time a database request is made it adds additional load to the server. Memcached reduces that load by storing data objects in dynamic memory (think of it as short-term memory for applications).

Should I use memcache or Redis?

Memcached is designed for simplicity while Redis offers a rich set of features that make it effective for a wide range of use cases. Understand your requirements and what each engine offers to decide which solution better meets your needs.

Why Redis is better than memcache?

When storing data, Redis stores data as specific data types, whereas Memcached only stores data as strings. Because of this, Redis can change data in place without having to re-upload the entire data value. This reduces network overhead.

What is memcache used for?

Memcached can serve cached items in less than a millisecond, and enables you to easily and cost effectively scale for higher loads. Memcached is popular for database query results caching, session caching, web page caching, API caching, and caching of objects such as images, files, and metadata.


1 Answers

https://github.com/steveyen/community-site/blob/master/db_doc/main/WhyNotMemcached.wiki

Memcached is terrific! But not for every situation...

  • You have objects larger than 1MB.
    • Memcached is not for large media and streaming huge blobs.
    • Consider other solutions like: http://www.danga.com/mogilefs
  • You have keys larger than 250 chars.
    • If so, perhaps you're doing something wrong?
    • And, see this mailing list conversation on key size for suggestions.
  • Your hosting provider won't let you run memcached.
    • If you're on a low-end virtual private server (a slice of a machine), virtualization tech like vmware or xen might not be a great place to run memcached. Memcached really wants to take over and control a hunk of memory -- if that memory gets swapped out by the OS or hypervisor, performance goes away. Using virtualization, though, just to ease deployment across dedicated boxes is fine.
  • You're running in an insecure environment.
    • Remember, anyone can just telnet to any memcached server. If you're on a shared system, watch out!
  • You want persistence. Or, a database.
    • If you really just wish that memcached had a SQL interface, then you probably need to rethink your understanding of caching and memcached.
like image 110
OZ_ Avatar answered Sep 20 '22 06:09

OZ_