Use TMPFS to accelerate your Linux server

xiaoxiao2021-03-06  68

BY

LANF, source: http://www.5ilinux.com/blog/archives/000075.html

Author: Zhang Chunhui high microwave today from a friend there and learned a trick is to use tmpfs, I took him to digest after the virtual disk to store the cache files and php seesion of the squid. Very few speed! The default system will load / dev / shm, which is the so-called TMPFS, some people say to ramdisk, but not the same. Like virtual disks, TMPFS can use your RAM, but it can also be stored using your swap partition. And the traditional virtual disk is a block device and requires a command such as MKFS to truly use it. TMPFS is a file system, not block devices; you just install it, it can be used. TMPFS has the following advantages: 1. Dynamic file system size, 2. Another major advantage of TMPFS is its lightning speed. Because typical TMPFS file systems will remain completely in RAM, read and write can almost instantly. 3. TMPFS data will not be retained after restarting, because virtual memory is essentially volatile. So it is necessary to do some scripts to do operations such as loading, binding. I have told some big truths. Let's see it, or talk about my app :) First build a TMP folder in / dev / STM, then bind MKDIR / DEV / SHM / TMPCHMOD with actual / TMP 1777 / dev / shm / tmpmount --bind / dev / shm / tmp / TMP 1. Squid's cache directory set vi /etc/squid/squid.conf Modified into cache_dir ufs / tmp 256 16 256 Here, the first 256 is used to use 256M memory, I think high-performance Linux dual-efficiency firewall Howto uses ramdisk's method is not as direct. With TMPFS, at least MKFS at least each time you start, you can also dynamically change the size. Then restart the service, OK, now all Squid cache files save in the TMPFS file system, soon. 2. Optimization of PHP performance For an Apache PHP website, there may be many temporary files under TMP, such as SEESION or some cache files, then you can save it to the TMPFS file. The way to save seesion is very simple. Just modify php.ini, because I have already bind / dev / STM / TMP and / TMP, so do not rewrite, as for the Cache file generated by the PHP program can change their own PHP program :) I hope that my method can inspire you. Reference documentation: Using Virtual Memory (VIRTUAL MEMORY, VM) file system and binding installation

转载请注明原文地址:https://www.9cbs.com/read-92571.html

New Post(0)