Back-end development-understanding of caching

Source: Internet
Author: User
Preface

Today I found a very good learning it knowledge of the website (also has the app), the name is nuggets, I predict this app should be fire, which collects a lot of good IT technology blog, gold is relatively high, also recommend to everyone, interested students can go to the site to see, really good yo. introduce

Well, back to the end, today in a blog to see the introduction of the backend development of the cache to say that is not bad, I think also write an article, record their own experience. The first thing you need to know is caching, and caching is actually a place to store data temporarily. The most important thing is to do background development, if the user spends a few seconds each time visiting a page, it's not going to explode. Then the cache also came into being, the cache has greatly improved the performance of the product, making the user's access more efficient.type of Cache Database-Type Caching: Database-type caching is the data stored in a relational database, the Key-value database in the form of data storage, so that can greatly speed up access efficiency. FILE-type caching: Database cache to remotely access the database speed or slow, the file-type database is the temporary storage of data to local files, access to local files faster than the remote database, so this file is a cache. Memory cache: In the further, access to the file is still a bit slow, then we can put some hot data directly in memory, so that access to memory faster than the file.So how do you design a cache? Underlying data structure: in the computer almost all the wheels have to consider data structure, and the quality of the bottom of the structure directly affect the efficiency of the system operation. For caching, generally is the form of key-value, so the bottom of the general use of trees or hash tables to store data, caching performance requirements are relatively high, so generally use a hash table to save data. Memory management: Because there is write operation, so you need to apply for memory, if you write more of the operation of the words plus some read the operation, then will continue to apply for the release of resources, this will affect performance, so generally use the memory connection pool to use. Network model: For the network model, in fact, modern high-level language has been basically encapsulated to the level of HTTP, such as Golang this modern language, HTTP packages can be used directly, and concurrency performance is good, but for a caching system, if with an HTTP model, it is too heavy , the TCP model under HTTP can solve the problem very well, for this piece, we can use a simple model: according to the core number of CPUs to start the corresponding number of the coprocessor, each of the coprocessor with a channel, start a coprocessor responsible for receiving TCP connections, Accpet link later through the channel to the corresponding coprocessor processing.

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.