Make memcached and mysql work better

Source: Internet
Author: User

This is the Fotolog experience. It is said that Fotolog has deployed 51 memcached instances on 21 servers and cached up to GB of content on 21 servers, this number is much larger than that of databases on many websites. The original Article is A Bunch of Great Strategies for Using Memcached and MySQL Better Together. Here I will continue to provide selective translation and supplement based on my understanding, thanks to Todd Hoff, we can always give us some learning cases. From here, we can also see the open attitude of foreign technologies, which is not like us. In fact, we are still waiting for the answer. Well, let's get started.

1. About memcached

Do not know this yet? When you go to the interview, you will suffer a loss. Please go to the official website to check your website (Facebook is in use), eaccelerator, or Xcache (developed by Chinese people). These products have better standalone performance, if you need a distributed cache solution, use memcached.

Ii. How does memcached work with mysql?

Database sharding is used to solve the problem of database write extension. Database sharding is deployed on different servers, so that there is no primary server, and write operations become bottlenecks and possible "single point of failure ", generally, database sharding mainly divides services according to the business, and splits services as much as possible. Unrelated data is made into services independently.

The front-end mysql server and a bunch of memcached servers are used to cope with read problems. The application first obtains data from memcached and then obtains data from the database and stores the data in memcached, I have read an article saying that 95% of the application data is obtained from memcache, 3% of the data is obtained from mysql's query cache, and 2% of the remaining data is used for table search. Compare your application, how far is the gap?

Solve the read problem through mysql replication (master-slave)

First, the mysql database uses master-slave read/write splitting and multiple slave operations to handle application read operations.

Iii. Why not use mysql query cache?

We all know that mysql has a query cache that can cache the results of the last query, but it does not actually help much. below is the insufficiency of mysql quety cache:

Only one instance can be created.

This means that the upper limit of the content you can store is the available memory on your server. How much memory can a server have? How much can you store?

Mysql query cache becomes invalid as long as there is a write operation.

As long as the database content changes slightly, other rows may be changed, and the query cache of mysql will also become invalid.

Mysql query cache can only cache database data rows

This means that no other content is available, such as arrays, such as objects. In theory, memcached can cache any content or even file ^_^.

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.