Cached in Linux memory is too large

Source: Internet
Author: User

Two machines are mainly used to run Nginx and PHP, the memory is 8G and 4G, a period of time after the output of the free command cached values will be more and more large,

Self-search a few laps later learned that cached is mainly responsible for cache file use, log file too large cause cached area memory increase memory occupied.
Buffer and cache in free: (They are all memory-intensive):
Buffer: Memory as buffer cache, which is the read and write buffer of the block device
Cache: As the page cache memory, the file system cache
If the cache has a large value, it indicates that the cache has a high number of files.

But there are still two questions:
1. What does the memory usage (cached occupancy) of the two machine used to run PHP have to do with the number of PHP requests? For example, these two stations, is not the number of visits, the cached value will be greater?

2. Does the sync command, after writing the cached to disk, have any impact on subsequent access?

I rookie, please the big God pointing ...

Reply content:

Two machines are mainly used to run Nginx and PHP, the memory is 8G and 4G, a period of time after the output of the free command cached values will be more and more large,

Self-search a few laps later learned that cached is mainly responsible for cache file use, log file too large cause cached area memory increase memory occupied.
Buffer and cache in free: (They are all memory-intensive):
Buffer: Memory as buffer cache, which is the read and write buffer of the block device
Cache: As the page cache memory, the file system cache
If the cache has a large value, it indicates that the cache has a high number of files.

But there are still two questions:
1. What does the memory usage (cached occupancy) of the two machine used to run PHP have to do with the number of PHP requests? For example, these two stations, is not the number of visits, the cached value will be greater?

2. Does the sync command, after writing the cached to disk, have any impact on subsequent access?

I rookie, please the big God pointing ...

Where is it too big? Cached and buffers occupy the majority of the available part is normal. You say your memory, free is useless, but you think those parts do not need to power, refresh it?

Cached usually belongs to the available section (which is provided after the data 3.14 kernel, and procps-ng is also shown in newer versions), which is available memory . When the program needs to be used, when to take it. Not needed for the moment? Then I'm going to keep the data from the slow-to-dead guy in the disk, which means the user has to use it.

Interested to be able to echo 3 to what file to /proc/sys/vm/drop_caches clear these parts, and then Ls/usr/lib try. And then execute it again immediately, is there a cache after it is much faster?

As for the sync command. It's about cached, but it's not what you think it is. Its function is to write the dirty page back to the disk, that is, the modified data is not written to the disk data written to disk. Because the kernel delays commits, it accumulates more data per commit to increase efficiency and reduce latency. No need to use, will only let the system card a bit. Bold text and bold text

Cached occupies a lot of no relationship ah, when necessary, the system will automatically recycle the file cache, and then assigned. If the cache needs to be written to disk, the filesystem will do it by itself, and there's no need to sync.

You can look at memory_limit=xxx in the PHP configuration file. May be able to help the landlord!

  • 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.