4

Just wondering, have you ever made anything useful with a RAM disk in production? I wonder if the performance benefit they afford possibly outweighs their temporary nature in a specific circumstance.

I've only ever used one once, and it wasn't for performance. It was when I needed some writable disk space on a server showing hard drive errors – it gave just enough space for me to install the 3ware RAID utility to identify the dodgy disk.

How have you used a RAM disk in production?

p.campbell
  • 4,397
  • 6
  • 40
  • 51
JamesHannah
  • 1,731
  • 2
  • 11
  • 22

23 Answers23

10

I setup a ramdisk on my mailgateway.
There clamav has a 256MB ramdisk for scanning attachements.

It runs since almost three years, I think its ok :)

ThorstenS
  • 3,084
  • 18
  • 21
  • I use a ramdisk for amavisd temp files on my mail server (running Zimbra), not only is it in production it's vendor supported to boot. – notpeter Oct 24 '10 at 18:03
7

Absolutely.

Diskless nodes that have their root FS on a read-only NFS share and strategically mounted tmpfs filesystems to allow writing to various parts of the filesystem hierarchy (eg: /tmp).

Kamil Kisiel
  • 11,946
  • 7
  • 46
  • 68
7

Nagios can use a ramdisk for dramatic performance increase as this guy figured out:

http://lickthesalt.com/2009/04/19/tweaking-nagios-for-performance/

Joseph
  • 3,787
  • 26
  • 33
4

Yup, Windows PE uses them for loading the PE environment into memory prior to imaging a PC.

I've always been attracted to the notion of using a RAM disk for my swap file location, but never really got round to trying it out, and to be honest I'm not totally certain how well it would work in practice.

Maximus Minimus
  • 8,937
  • 1
  • 22
  • 36
  • 11
    Why would you use a RAM disk for your swap when Windows would rather use that RAM for... RAM? – Ernie Jul 22 '09 at 21:03
  • In the same vein, all LinuxLIVE disks use a RAM disk for their filesystem. – sysadmin1138 Jul 22 '09 at 21:10
  • 2
    @Ernie: I marked up your answer cos it tickled my funny bone. So true. It was mostly back in the Windows 98 days and would have been a symptom of frustration at constant hard disk grinding. :) – Maximus Minimus Jul 22 '09 at 21:14
  • 1
    There is a RAM disk (sorry, can't remember it's name) that allows you to use the memory above the 3GB limit on a 32bit OS to create a RAM disk. This is specifically for the swap file. – pipTheGeek Aug 19 '09 at 17:39
  • @pip Now, that would actually make some sense. – Skyhawk Sep 27 '11 at 20:04
4

A common use is to put MySQL's tmpdir on a ramdisk (e.g. tmpfs) if your web application creates a lot of on-disk temporary tables, i.e. Created_tmp_disk_tables is large and getting larger all the time.

Cheers

HTTP500
  • 4,827
  • 4
  • 22
  • 31
3

My netbook rsyncs my Firefox profile to a RAM disk on boot, removing the very slightly irritating pauses caused by the urlclassifier file being updated on the not-fast-to-write-to SSD after page loads. It rsyncs it back on full shutdown so new bookmarks and such are not lost between boots (using the inplace option which reduced the number of writes needed in the simple tests I performed) or when I command it to (i.e. after making a number of changes like installing+configuring plugins).

They are also useful for some performance tests when you don't want disk IO to have much impact on the test but /dev/zero and friends won't do for some reason.

David Spillett
  • 22,534
  • 42
  • 66
  • I really like the idea of using to hide the write penalty of SSD. Heck you could even have a directory watcher of sort watch key folders/files (like your bookmarks) and sync them on change in the background. Very cool. – Goyuix Jul 22 '09 at 23:02
3

They're most useful when going totally disk-less, or when using the disks only for a particular format that the OS wouldn't boot from.

I know it's not a server, but on old macs you used to be able to set a ram-disk up and then install a minimal OS 7 into it, set it as your boot volume, then reboot from it. It seemed scary, but it always worked, and it definitely made the finder act more responsive. Some claimed it even made photoshop run faster, but I was never clear on that.

dlamblin
  • 929
  • 2
  • 10
  • 20
3

On a firewall the hard drive was replaced with a compact flash card. A RAM drive is used because CF cards have limited write cycles. On shutdown anything in the RAM drive that needs to be preserved is transferred to the CF card and reloaded on reboot. I am currently looking into creating Linux thin clients using the same idea.

John Gardeniers
  • 27,262
  • 12
  • 53
  • 108
2

you can store small but frequently r/w files on ramdisk. Some uses I do:

  • syslog goes to tmpfs /tmp on my laptop: it helps drives spinoff if I don't use the computer (reduces writes)
  • /tmp is good on tmpfs, as many apps are using it as temporary dir (mysql for temptables, virus scanners and some packaging utility, for example)
  • php session file store: on debian systems, /var/lib/php[45] is always mounted by tmpfs to reduce writing to disk (as my disks are always raid1, writing is quite a pain)
  • as mentioned, mail scanner tools are thankful for infinite speed block devices :)
  • files for AJAX: these files here are frequently regenerated

You should check your applications where you have opportunity. A directory qualified to go under tmpfs, if the content

  • would be regenerated anyway (like ajax support files)
  • does not have to survive a reboot
asdmin
  • 2,020
  • 16
  • 28
1

There are legitimate uses for a RAMDISK, but not many. The system cache provides most of the benefits of a RAMDISK without the disadvantages. A RAMDISK requires tying up a substantial amount of RAM when it may be better used for other purposes. You will often optimize one aspect of performance but lose it elsewhere.

Incidentally, using a RAMDISK for the pagefile is completely nonsensical. In virtually every case it will be better to let the system use the RAM as it sees fit.

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
Larry Miller
  • 215
  • 2
  • 2
0

I have a 64GB RAM server and running a 40GB Ramdisk :)

On the ramdisk I have the vhd files of the virtual machine which runs under Hyper V.

Windows Server 2008 R2 boots up in 2 seconds. Everything it's about 10 times at least faster :)

Adaptabi
  • 175
  • 3
0

My home server runs an Internet proxy (FreeProxy). Since it's a cheap server, and the hard disks aren't the fast ever, I use a 1GB RAM disk for the location of the proxy cache files. Makes a huge difference in performance, and only gets lost when the server is rebooted (once a month or so depending on Windows Updates!).

0

With Solid State Drives getting bigger and cheaper ( $1-$2 per GB for the smaller disks as of this writing ) every week, with write cycles in the 10's of years of 24/7/365 use, DRAM based RAM disks are getting less and less viable.

0

Been using ramdisks for 35 years. Best use is for disk caching files, I use a notebook XP Pro with 3.24 gigs for OS (max) and .76 gig for swap file.
It smokes.....

0

Generally, they're a waste of memory since the OS is often very good at deciding how to use available RAM.

Geoff Fritz
  • 1,717
  • 9
  • 11
  • 5
    -1: He is not asking should you, but what have you done with it in production. – Robert MacLean Jul 23 '09 at 08:23
  • If the OS would have a switch that would tell it "please cache this folder to RAM at all times because it's my performance bottleneck" then I would agree with you. Otherwise you can often notice considerable performance improvements when you use a RAMDisk for caching some often-used data. – Vilx- Dec 01 '09 at 10:37
0

I haven't seen ram disks used for a long time, but I think that's because tools like memcached allowing for greater scaling and the fact that you can get such fast hard drives now (thinking of SSD drives) that performance is not such a consideration (see this post for how it didn't make any major differences).

An example of an interesting using of memcachd is Twitter. A very smart idea for ramdisks is a privacy system, especially for local user - just think shutdown and the data is gone (idea from Surasoft).

Robert MacLean
  • 2,186
  • 5
  • 28
  • 44
0

Back when I ran sendmail, I used a ramdisk (technically, Linux tmpfs, but it's functionally the same thing) for the hoststat database. It takes up very little room, but it creates a ton of inodes. Sendmail didn't (at the time) do any housekeeping on it, and it grows quickly even on a modestly busy mail server. I used a ramdisk so my cleanup script wouldn't cause the disks to thrash about due to all the directory lookups.

James Sneeringer
  • 6,755
  • 23
  • 27
0

Solaris mounts /tmp in ram (or swap, depending on how you look at things), and you can set up Linux to do the same. Ages ago, I had a the same set up on my OS/2 box, I'd unpack stuff there, and it was good for a speed improvement (original was on disk, not having to hit disk was a win, and OS/2 had a fixed size disk cache).

Ronald Pottol
  • 1,683
  • 1
  • 11
  • 19
0

Although it's not literally a RAM disk, the architecture of Mailinator is in the same spirit. Basically, since the content Mailinator handles is not 'valuable', they can afford the risk of its loss to dramatically improve performance.

Phil Miller
  • 1,725
  • 1
  • 11
  • 17
0

You're using them with every boot of your system :)

By putting eventually needed driver modules into the ramdisk, you can keep a small, modular kernel, and still boot from many different devices (from a "normal" disk, over different raid controllers to a root filesystem on a network via NFS) - without having to compile your drivers into the kernel.

That alone should be enough reason for ramdisks to exists :)

And then, although I never used one for anything else but the above, yes, they can be useful in situations where you have some reasonable amount of larger temporary data to write very often, where it might not be a big thing when it get's lost in the probably rare case a server goes down, and very fast reading and writing is required

Henning
  • 246
  • 1
  • 3
0

We find that using a RAMDISK as the location for the SCRATCH files in Fortran really helps when you're using circa-older-then-me software on really large datasets :)

mwalling
  • 511
  • 2
  • 5
  • 12
0

I use a ramdisk for compiling (/tmp is set up as tmpfs on my computer). I've never bothered timing it though.

On Windows I used to use a ramdisk as my scratch disk in Photoshop (since it insists on using one even if you have way more memory than it needs). I think it would be interesting to put the textures folder for World of Warcraft on a ramdisk, but I stopped playing before I got enough memory to try it.

Brendan Long
  • 342
  • 1
  • 11
0

I store sessions in mysql on a RAM disk. Much better than the memory table type as you can have indexes, and fewer contention problems and write delays than hoping that the system will sort it out - databases want to make sure your data is secure, we don't really care, just want it fast. Scheduled reboots can copy to disk then back (though we tend to just let the sessions expire), and it was less work to implement than changing the sessions store to use memcached (you can't do queries to expire old sessions in memcached - it's not as simple as letting them expire).

davidsheldon
  • 381
  • 2
  • 7