• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Memory vs. Harddisk???

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Could anyone suggest which is the best approach for the Server. Should data be held in memory (e.g. as a Vector) until the server is shutdown and then written to the db file. Or should the db file be constantly updated when a delete/create/update functions are called on the server.

I would prefer holding the Server data in memory until the server is shut down. I was going to justify this design choice with the following points in my choices.txt ...

Memory is cheap (a couple of thousand entries should not be a problem)
Simplier design (more maintainable)
Faster access times

Do you think this would be acceptable solution. Has anyone heard if keeping all the data in memory until shutdown is a no no.

Thanks,
Jon
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

How about doing both - keeping it in memory for fast access, and writing it to disk for safety? Imagine someone tripping over a wire while nothing has been written to disk yet (yes, it does happen, even in hosting centers).
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to prevent dataloss I keep everything on disc.
I don't even use a disk cache at the moment (though I could implement one) because it's IMO beyond the scope of the assignment (a small scale system).

When and if performance becomes an issue (which isn't listed in the requirements) a cache could easily be added.
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Jon

I keep in memory only a Map of record indexes(valid and active records).

Jeroen, you must do the something similar ? What you mean by :


I keep everything on disc.




Regards M
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the only thing I keep in memory is the locks (of course) and a list of records that were deleted during the current session (just as a slight performance boost when inserting a new record, to prevent a complete tablescan for empty space).
 
reply
    Bookmark Topic Watch Topic
  • New Topic