We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

Advice: Using RAMDisk


Iray
14-05-2009, 20:06
Quote Originally Posted by Ashley
Think about putting your database into memory too. Obviously depending how large it is.
[...]
Stuff like user info, etc is ideal because its always requested.
Im not sure how this would be achieved with RAMDisk.
I would refrain from caching tables or databases altogether, would be a pain to script and you would need to update the cache everytime the db is updated or setup a cron every 5 mins - too much headache.

A better solution already exists, Memcached with MYSQL would achieve this and has many other useful features.
Read the official docs:
http://dev.mysql.com/doc/refman/5.1/...memcached.html

Quote Originally Posted by gigabit
This looks pretty cool, I was thinking about copying all the files for my site (inc php) into a ramdisk to lighten the load on the hard drives and maybe make things a bit faster but would this make a difference, arent files already cached in RAM? I'm using lighttpd on Fedora.
I don't think files are automatically cached. I would assume they would need to be compiled beforehand, extensions already exists for this, eaccelerator is one of them. Once a PHP script is compiled it is then stored into RAM - removing the need to be read and compiled next time it is accessed.

So, to add:
Use an opcache + Cache generated content routinely + Store in RAM = Performance goodness

Ashley
12-05-2009, 10:30
Quote Originally Posted by monkey56657
MySQL can cache entire tables already.... or just common queries... whatever.. So i see no need for this
The MEMORY engine loses all its data when the system is shut down so is not a viable means of storage which is why I mentioned about pre-loading the data. MySQL cache's queries, correct - however if you are running a busy website your real time queries won't be cached. Such as listing posts from a forum/thread.

freshwire
08-05-2009, 16:57
MySQL can cache entire tables already.... or just common queries... whatever.. So i see no need for this

Ashley
08-05-2009, 14:06
Think about putting your database into memory too. Obviously depending how large it is.

You can write scripts that will copy a table into memory and back it up onto disk before shut down.

Stuff like user info, etc is ideal because its always requested.

gigabit
05-05-2009, 17:54
This looks pretty cool, I was thinking about copying all the files for my site (inc php) into a ramdisk to lighten the load on the hard drives and maybe make things a bit faster but would this make a difference, arent files already cached in RAM? I'm using lighttpd on Fedora.

Palad1n
05-05-2009, 10:19
Hi,

I do this using NGINX, but I have a script in rc.local that stops the Web Server, creates RAMdisk, copies files from /var/www/cacheme to the ramdisk then starts the Web Server, which has it's home drive set as /var/www/ramdisk.

Works great on RPS, for static files.

I run the script every 6 hours, so if I update files the changes take effect.

freshwire
03-05-2009, 16:16
My shared hosting service is offering up to 2MB ram space per client for this very purpose

Iray
02-05-2009, 22:53
Hello all,

Some days ago, I was attempting to optimize the performance of my site, this involved caching static versions of my dynamically generated site.
However i faced a small problem, once cached you will typically store it somewhere on your SAN, I figured its a better idea to use of RAM instead for that extra boost - SAN is much slower then RAM.

So instead of storing your cached versions on your network disk, place it into RAM to increase speed and performance.
Before you begin i would suggest the following:

- Make it small - No need to reserve too much memory.
A typical page would be 10-20kb, reserve accordingly (max 5-10 MB).
That said, if you reserve to much it will have reverse effects - applications will begin using SWAP if there is not enough RAM available, significantly slowing down performance.

- Do not store essentials on your RAMDisk
Since you're using RAM - anything stored on it will be lost after a reboot. Do NOT store system files etc..

- Limit what you cache
Try not to cache everything, stick to your main page and perhaps other resource hungry pages. Remember, static pages (like .html) are non dynamic - no need for those!

- Not limited to caching
RAMDisk is not limited to just caching. Perhaps store something you use alot?


To learn how to set up RAMDisk , follow the link below
http://www.vanemery.com/Linux/Ramdisk/ramdisk.html

I hope this was useful to you! If you have any questions let me know.

iray