Make memcached and MySQL work better.

Source: Internet
Author: User
Tags memcached mysql query mysql database

This is Fotolog's experience, the legendary site more than Flickr, Fotolog deployed 51 memcached instances on 21 servers, a total of 254G cache space available, cache up to 175G of content, this number is much larger than the database of many sites, The original is a Bunch of great strategies for Using Memcached and MySQL Better together, here I am still a selective translator and, in my understanding, thanks to Todd Hoff, who can always give us some study cases. For example, from here also can see foreign technology open attitude, not like us, in fact, so little 99 still tucked away, OK, get to the point.

First, about memcached

You don't know that? Then you go to the interview time to suffer, and hurriedly go to the official website to look at http://www.danga.com/memcached/, another Google use, hard drive is always too slow, put the data in memory inside it, if you have only one server, It is recommended to use an APC (Facebook is in use) or Eaccelerator or XCache (developed by the people), these products are better than stand-alone, if you need a distributed caching scheme, then use memcached bar.

Second, how memcached and MySQL fight alongside?

Database fragmentation is used to solve the problem of database write extension. Deployed to different servers, so that there is only one primary server, write operations become a bottleneck and possible "single point of failure", the general database fragmentation is mainly according to the business, as far as possible split the business, irrelevant are independent to make services or

Front-End MySQL and a bunch of memcached servers to deal with read problems the application first obtains the data from the memcached, obtains from the database and saves in the memcached, previously read an article to say well the application 95% data obtains from the Memcache , 3% of the data from the MySQL query cache to obtain, leaving 2% to check the table, compare your application, how far is the gap?

Solve read problems with MySQL replication (master-slave)

First MySQL database through Master-slave read-write separation, multiple slave to respond to the application read operation.

Third, why not use the MySQL query cache?

We all know that MySQL has a query cache, you can cache the results of the last query, can not actually help too much busy, the following is the MySQL quety cache:

There can only be one instance

means that the upper limit of what you can store is your server's available memory, how much memory can a server have? How much can you save?

MySQL's query cache fails as long as there is a write operation

As long as the database content changes slightly, that is afraid to change the other lines, MySQL query cache will also be ineffective

The MySQL query cache only caches database data rows

That means nothing else, like arrays, like objects, and memcached can theoretically cache anything or even file ^_^

Related Article

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.