Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

Memcached Interview Questions


A list of top frequently asked Memcached interview questions and answers are given below.


1) What is Memcached?

Memcached is a general purpose free and open source, high performance, distributed memory object caching system. It is used to speed up database-driven websites by caching data and objects in RAM.

In simple words you can say that, Memcached is a component which stores data temporally for 1hour/ 6 hour/ 12 hours/ 1 day etc. and you can integrate this component with your applications to increase their performance.


2) In which language Memcached is written and who is the author?

Memcached is written in “C language” and it is written by Danga Interactive.


3) In which websites and services Memcached is generally used?

Memcached can be used for:

  • Social networking sites for profile caching
  • For content aggregation i.e. HTML/Page caching
  • In E-commerce websites for Session and HTML caching
  • In location based services for database query scaling
  • In gaming and entertainment services for session caching
  • It can also be used to track cookie/ profile for ad targeting.

4) What is the best usage of Memcached?

Best usage of Memcached:

  • It is easy to install in Windows as well as in UNIX operating system.
  • It provides API integration for all the major languages like Java, PHP, C/C++, Python, Ruby, Perl etc.
  • It enhances the performance of web application by caching.
  • It reduces the burden of database server.
  • It facilitates you to delete one or more values.
  • It facilitates you to update the values of keys.

5) What are the drawbacks/ limitations of Memcached?

A list of limitations or drawbacks of Memcached:

  • It cannot store data persistently and permanently.
  • It is not a database.
  • It cannot cache large objects.
  • It is not application specific.
  • It is not fault-tolerant or highly available.

6) In which conditions cache cannot retain the stored information?

Cache cannot retain the stored information in following conditions:

  • When memory allocated for the cache is exhausted.
  • When item form cache is deleted.
  • When individual item in the cache is expired.

7) What is the difference between Memcache and Memcached?

Difference between Memcache and Memcached:

Table:

Memcache Memcached
Memcache is an extension that allows you to work through handy object-oriented (OOP’s) and procedural interfaces. Memcached is an extension that uses libmemcached library to provide API for communicating with memcached servers.
it is designed to reduce database load in dynamic web applications. it is used to increase the dynamic web applications by reducing database load. It is the latest api.

8) Is it possible to share a single instance of Memcache between multiple projects?

Yes, it is possible to share a single instance of Memcache between multiple projects because Memcache is a memory store space and it can be run on one or more servers. You can also run two different Memcache processes on the same host and yet they are completely independent.


9) If you have multiple Memcache servers and one of the memcache server fails which has your data, will it ever try to get key data from that one failed server?

The data in the failed server won’t get removed, but there is a provision for auto-failure, which can be configured for multiple nodes. Fail-over can be triggered during any kind of socket or Memcached server level errors and not during normal client errors like adding an existing key, etc.


10) How can you minimize the Memcached server outages?

Following are the methods to minimize the Memcached server outage:

  • When one instance fails, several of them goes down, this will put larger load on the database server when the client reloaded the lost data. To avoid this, you should write your code to minimize cache stampedes, it will leave a comparatively less impact.
  • You can bring up an instance of Memcached on a new machine using the lost machines IP address.
  • Code is another option to minimize server outages as it gives you the liberty to change the Memcached server list with minimal work.
  • Setting timeout value is another option that some Memcached clients implement for Memcached server outage. When your Memcached server goes down, the client will keep trying to send a request till the time-out limit is reached.

11) How can you update Memcached when data changes?

There are two ways to update Memcached when data changes:

By clearing the cache proactively: You can update memcached by clearing the cache when an insert or update is made.

By resetting the cache: It is slightly similar to the first method but rather than just deleting the keys and waiting for the next request for the data to refresh the cache, it resets the values after the insert or update.


12) What is Dogpile effect? How to prevent this effect?

Dogpile effect is a situation when cache expires, and websites are hit by multiple requests made by the client at the same time.

You can prevent this effect by using semaphore lock. In this system when value expires, first process acquires the lock and starts generating new value.


13) If server gets shut down then data stored in Memcached is still available?

In Memcached, data is not permanently stored. This data is not durable so if the server is shut down or restarted then all the data stored in Memcached is deleted.


14) What is the difference between SAP HANA and Memcached?

SAP HANA is an in-memory RDBMS and mostly used for accelerating SAP applications while Memcached is a key/value caching system and used for accessing both RDBMS and NOSQL databases.


15) How to connect Memcached server with telnet command?

By using this memcached command:

telnet ostname portNumber


16) How to get the value of key?

By using this command:

get key


17) How to set the value of key?

By using this format:

set[key][flags][exptim][bytes][noreply]


18) How to add value in key?

By using this format:

add[key][flags][exptim][bytes][noreply]


19) How to replace the value of key?

By using this format:

replace[key][flags][exptim][bytes][noreply]


20) How to append the value of key?

By using this format:

append[key][flags][exptim][bytes][noreply]


21) How to prepend value of key?

By using this format:

prepend[key][flags][exptim][bytes][noreply]


22) How to delete the key?

By using this command:

delete key


23) How to show the stats?

By using this command:

stats


24) How to get the versions?

By using this command:

Version


25) How to close the connection?

By using this command:

Quit

Comments

comments