Can the database reside in RAM?

Discussion in 'Domains, Hosting and Servers' started by Abomination, Oct 29, 2009.

  1. Abomination

    Abomination Zealot

    Joined:
    Jun 1, 2009
    Messages:
    1,514
    Likes Received:
    102
    This probably a really dumb question but can the database be kept in RAM?

    Lets say there is a 500MB database, and 4GB of ram on a dedicated server, couldn't the database and all necessary files reside in ram? Or maybe a 100MB database and 768MB ram on a servint vps.


    Like I said, probably a dumb question.

    ?
     
  2. MjrNuT

    MjrNuT Grand Master

    Joined:
    Oct 14, 2009
    Messages:
    579
    Likes Received:
    36
    Not a dumb question at all. Short answer is No.

    Long answer

    Even longer answer.
     
  3. Abomination

    Abomination Zealot

    Joined:
    Jun 1, 2009
    Messages:
    1,514
    Likes Received:
    102
    I have the basic concept of ram vs hard disc, ram is volatile/not permanent and the contents disappear when re-booted or powered off. I am also familiar with a ram disc where the ram is treated as a disc.

    I know nothing regarding configuring a server though. From my noobs perspective it would seem that if there was enough ram that it would not need to read/write to the disc often, I believe the term was 'flush' at one point in time.

    How are they normally configured? My shared hosting account I am sure minimizes ram use, if I go to a vps or dedicated could it all, for the most part, run out of ram?

    :shrug:
     
  4. MjrNuT

    MjrNuT Grand Master

    Joined:
    Oct 14, 2009
    Messages:
    579
    Likes Received:
    36
    I have no direct experience with a VPS, however, they are allotted in sizes by RAM. Hence, your question it. Someone here may be able to speak better about it, but it really comes into play for cpu cycles...I think.

    You need sufficient RAM to run simultaneous operations. That is its primary purpose, however, it has its limits. So, chunks are thrown to the RAM, so to speak. In a VPS environment, you can run out of RAM, but I'm not sure what the typical situations are that do this exactly. I suspect large about of hits because the host is serving so many pages. Or large database operations. Streaming video maybe.

    It will similar in concept to shared and dedicated, with an exception...the cpu contribution. Dedicated is self explanatory. By todays uses, I think 2GB of RAM is sufficient for web hosting.

    Shared at the bottom of the spectrum is even more restrictive of course. Streaming video/audio may be off limits depending on its distribution. If your site gets too much traffic, that is not good for shared.

    I don't know if I'm answering your questions. I've done my research in the past on sites like WHT. or links like this.

    Essentially, a dedicated is mostly unmanaged and a VPS is managed. Sorry if I'm not that helpful.
     
  5. kev

    kev Regular Member

    Joined:
    Mar 9, 2009
    Messages:
    1,224
    Likes Received:
    61
    I dont see why not?

    I think people might be getting "storing" the database in ram, as compared to "loading" the database into ram.

    There are customizations where the entire operating system can be loaded into ram from the hard drive. When the system starts up, it pulls the operating system from the hard drive, and stores it into memory. Only when changes are made will the operating system write to the drive.

    So why not be able to load a database into memory? Only when changes are made, will the hard drive be written to.

    There have been tweaks around for years that makes XP load the entire operating system into memory for faster response time. There was even a write up about it in PC Magazine a few years ago - I remember reading it. But I can not find the printed article on the internet right now.

    brainstorm.ubuntu.com/item/3745/ - discussion about ubuntu loading the kernal into memory upon start up.

    If its possible to load the operating system into memory, why not the data base? That would eliminate seek times to look up database information. Only when the changes are made to the database would the hard drives be written to.

    After doing a couple of searches, this is what I came up with.

    MySQL :: MySQL 5.0 Reference Manual :: 13.4 The MEMORY (HEAP) Storage Engine

    It looks like mysql can load the database into memory for faster performance.
     
    2 people like this.
  6. Abomination

    Abomination Zealot

    Joined:
    Jun 1, 2009
    Messages:
    1,514
    Likes Received:
    102
    Thanks Kevin.

    Perhaps someone else might comment in the future, either way I feel more confident taking the idea/question a little farther.

    One of the good things about AA is noob questions are not discouraged. : )
     
  7. David

    David Regular Member

    Joined:
    May 30, 2003
    Messages:
    1,088
    Likes Received:
    133
    Location:
    Australia
    But wouldn't loading a database into RAM be highly suboptimal in most conditions? Since most databases are being written to constantly, it seems like it would cause a lot of over head?
     
  8. MjrNuT

    MjrNuT Grand Master

    Joined:
    Oct 14, 2009
    Messages:
    579
    Likes Received:
    36
    Maybe I misunderstood, but I took your question to mean in a sense, only use RAM for which the db resides and operates solely. Hence, my answer is no. This is because the RAM is always in use, furthermore, not all of it can be used by said operation as the rest is for OS usage.

    However, all programs will use RAM. Ergo, mysql will use RAM as data is buffered into it. Can you optimize db usage with RAM, yes you can. Looks like mostly for *nix, which I am no expert in.

    My search.

    I still don't think RAM can be used as a storage type solution for a mysql dbase, as it is finite. This was my interpretation of the OP.

    Maybe you explain a bit more of where your question is coming from?
     
  9. Abomination

    Abomination Zealot

    Joined:
    Jun 1, 2009
    Messages:
    1,514
    Likes Received:
    102
    LOL... that is the problem, I am not acquainted enough with the terminology to form a clear question.

    I keep reading the 'server optimization requests' at vb.com and it occurred to me that instead of constantly reading/writing to disk and using little ram, there may be a way of taking advantage of ram if it was available.

    Example: if a forum is running fine but is only utilizing a small amount of ram (however it is configured). If there were additional ram available being unused, could that be utilized? Especially if the database was small in comparison to the ram available.

    In your link, I found this link, which is written in a way that I can understand better, thanks!
    InformIT: Optimizing and Tuning Your MySQL Database > MySQL Startup Options
     

Share This Page