Linux系统中的缓存策略主要涉及文件系统缓存、内存管理以及磁盘I/O调度等方面。以下是一些常见的缓存策略选择:
Page Cache
/proc/sys/vm/drop_caches
文件手动清理页缓存。Buffer Cache
Dentry Cache
Inode Cache
Slab Allocator
Overcommit Memory
/proc/sys/vm/overcommit_memory
设置:
0
: 启用启发式过量分配1
: 总是允许过量分配2
: 仅在显式请求时允许过量分配Swappiness
/proc/sys/vm/swappiness
调整。Large Pages
/proc/sys/vm/nr_hugepages
设置大页的数量。CFQ (Completely Fair Queuing)
Deadline
NOOP (No Operation)
Anticipatory
Memcached
Redis
Lru_cache
Ehcache
vmstat
, free
, iostat
等工具监控系统的内存和I/O性能。sysctl
命令调整内核参数以优化缓存行为。总之,Linux提供了丰富的缓存策略选项,可以根据具体应用场景和性能要求进行选择和调优。