Memcached FAQ (3) performance and client library Problems

Source: Internet
Author: User
Tags object serialization

 

Last updated by dormando@rydia.net
I have collected Frequently Asked Questions about memcached.

  • Performance problems

    • Memcached is faster than my database. Why?
  • Client library Problems
    • What client libraries does memcached have?
    • Can I access the same data in memcached using different client libraries? (Can different client libraries work together ?)
    • What is a client with consistent hash?
  • Client FAQ

Performance problems 

Memcached is faster than my database. Why?
In one-to-one comparison, memcached may not be faster than your SQL query. However, this is not the design goal of memcached. Memcached aims at scalability. When connections and requests increase, memcached performs better than most databases. You can test your code in a high-load environment (concurrent connections and requests) Before deciding whether memcached is suitable for you.

Client Library 

What client libraries does memcached have?
See the "how to access memcached" section above.

Can I access the same data in memcached using different client libraries?
Technically, yes. However, you may encounter the following three problems:

  • Different databases use different methods to serialize data. For example, the cache: memcached of Perl uses storable to serialize complex data (such as hash references and objects ). Client libraries in other languages may not be able to read data in this format. If you want to store complex data and want to be read by multiple client libraries, you should store the data in a simple string format, which can be parsed by external libraries such as JSON and XML.
  • Similarly, data from a client is compressed, but data from another client is not compressed.
  • Different client libraries may use different hash algorithms (phase 1 hash ). When connecting to multiple memcached servers, the client library maps keys to a memcached server based on its own hash algorithm. Because different client libraries use different hash algorithms, the keys mapped to memcached A by the Perl client library may be mapped to memcached B by the python client library. The Perl client library also allows you to specify different weights for each memcached, which is also a cause of this problem.

What is a client with consistent hash?

The consistent hash algorithm is a new approach to manage the first-layer hashing System for memcached clients. Here is an article that explains its usefulness well: http://www.last.fm/user/RJ/journal/2007/04/10/392555.

 

Client FAQ

There are currently some records:
The client can set a domain (namespace) for the key through the "prefix ). For example, in a shared host environment, you can use the customer name as the "prefix" to create a specific domain for the key. When storing data, the "prefix" can be used on the key, but should not be involved in hash calculation. Currently, memcached has not yet implemented its own serialization method for complex structured data. JSON is a widely used Object serialization format.

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.