Use tmpfs to accelerate your linux Server-Linux Enterprise Application-Linux server application information. The following is a detailed description. Today, I learned another trick from my friend Gao chunhui, that is, using tmpfs. After I digested it, I used it to implement a virtual disk to store squid cache files and php seesion. Fast!
By default, the system will load/dev/shm, which is called tmpfs. Some people say it is different from ramdisk (Virtual Disk. Like a virtual disk, tmpfs can use your RAM, but it can also use your swap partition for storage. In addition, a traditional virtual disk is a block device and requires commands such as mkfs to actually use it. tmpfs is a file system, not a block device. You only need to install it, it can be used.
Tmpfs has the following advantages:
1. The size of the dynamic file system,
2. Another major benefit of tmpfs is its lightning speed. Because the typical tmpfs file system will completely reside in RAM, reading and writing can be almost instantaneous.
3. Tmpfs data will not be retained after restart, because the virtual memory is essentially easy to lose. Therefore, it is necessary to execute some scripts such as loading and binding.
Well, I have explained some things and I am tired of reading them. Let's talk about my applications :)
Create a tmp folder in/dev/stm and bind it to the actual/tmp folder.
Mkdir/dev/shm/tmp
Chmod 1777/dev/shm/tmp
Mount -- bind/dev/shm/tmp
1. Squid cache directory settings
Vi/etc/squid. conf
Modify
Cache_dir ufs/tmp 256 16 256
Here, the first 256 indicates that the memory is mb. I think the ramdisk usage method of high-performance LINUX dual-effect firewall HOWTO is better than directly using tmpfs. At least mkfs is not used at each startup, and the size can be dynamically changed.
Then restart the service. OK. Now all the squid cache files are saved in the tmpfs file system, and soon.
2. Optimization of php Performance
For an apache + php website with a large access volume, there may be a lot of temporary files under tmp, such as seesion or some cached files, you can save it to the tmpfs file.
The method for saving the seesion is simple. You only need to modify php. ini is enough. Since I have bound/dev/stm/tmp to/tmp, I can do it without rewriting, as for the cache files generated by the php program, you can only change your php program :)
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.