GIT – Doftware RAM use the normal RAM in main memory as if it were a partition on a hard drive rather than actually accessing the data bus normally used for secondary storage such as hard . How do I create and store a web on a RAM to improve the speed of loading pages under operating systems?

You can create the ram disk as follows (8192 = 8M, no need to format the ramdisk as a journaling file system) :
# mkfs -q /dev/ram1 8192
# mkdir -p /ramcache
# mount /dev/ram1 /ramcache
# df -H | grep ramcache

Sample outputs:

/dev/ram1              8.2M   1.1M   6.7M  15% /ramcache

Next you copy images or caching objects to /ramcache
# cp /var/www/html/images/*.jpg /ramcache
Now you can edit Apache or reverse proxy to use /ramcache to map to

     DocumentRoot /ramcache
     #ErrorLog /var/logs//images.example.com_error.log
     #CustomLog /var/logs//images.example.com_access.log combined

Reload httpd:
# service httpd reload

Now all hits to will be served from the ram. This can improve the speed of loading pages or images. However, if rebooted all data will be lost. So you may want to write /etc/init.d/ script to copy back files to /ramcache. Create a script called

mkfs -t ext2 -q /dev/ram1 8192
[ ! -d /ramcache ] && mkdir -p /ramcache
mount /dev/ram1 /ramcache
/bin/cp /var/www/html/images/*.jpg /ramcache

Call it from /etc/rc.local or create softlink in /etc/rc3.d/
# chmod +x /path/to/
# echo '/path/to/' >> /etc/rc.local

A Note About tmpfs

tmpfs is supported by the Linux from version 2.4+. tmpfs (also known as shmfs) is a little different from the Linux ramdisk. It allocate memory dynamically and by allowing less-used pages to be moved onto swap space. ramfs, in contrast, does not make use of swap which can be an advantage or disadvantage in many cases.

Print Friendly



Bài viết liên quan