• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to copy datas in RAM to harddisk before the server shutdown?

 
hi ruben
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HELP: How to copy datas in RAM to harddisk before the server shutdown?

Thanks for your help!
I am now working on a voting system.In order to get better performance,I didn't use any database. All the datas was store in RAM.Howerver,that brings a problem. When the server shutdown, the voting infomation will be lost.
I am seeking for a way that can copy the RAM to the harddisk before the server shutdown.
I have tried that by asp before. But by jsp i am not sure whether it can be done.
Eagerly waiting for your reply! Thanks.
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make a database and use JDBC to insert the dates in that Database table. so simple.
 
hi ruben
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't use database in order to get a better performance, cause we have a lot of users. That will be very slow. So we store the voting result in RAM all over the process
 
Rufus BugleWeed
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put your data in an entity bean.
 
danny liu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a ContextListener to your voting system.
When the application is shutting down, back up the data into a text file on your hard disk.
When the application restarts, recover the data using that text file.
Hope it helps.
Dan
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you actually measure the performance when writing this file to disk or are you just guessing that it will slow things down?
How big is this block of data anyway?
Bill
 
hi ruben
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by danny liu:
Add a ContextListener to your voting system.

How does that work? Can you send me some samples,thanks very much!
is there anyone who know how the serverlet destroy() method or jsp's jspDestroy work?
Can i add some codes in the destroy() method to copy the ram to harddisk before the server shutdown?
 
Brahim Bakayoko
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by hi ruben:
HELP: How to copy datas in RAM to harddisk before the server shutdown?

Thanks for your help!
I am now working on a voting system.In order to get better performance,I didn't use any database. All the datas was store in RAM.Howerver,that brings a problem. When the server shutdown, the voting infomation will be lost.
I am seeking for a way that can copy the RAM to the harddisk before the server shutdown.
I have tried that by asp before. But by jsp i am not sure whether it can be done.
Eagerly waiting for your reply! Thanks.

Any kind of power or some application server issues will cause you to lose the in memory data, and the amount of data will be limited by the physical memory. Your voting system will be extremely unreliable.
Anyway, you can save the references of the data into the application context, then make use of the context events and listeners to write the serialized data to disk when the application is shutting down.
Note that the data is flushed out of memory when the application is shut down by the application server and not just when the physical server shuts down.
A well designed database even on a standard desktop system can handle hundreds of users per second. I am very sure that even a small database can handle your load unless your are designing a voting system for the national election, which I really hope not.
Even large vote tracking sites like opinionLab don't have 10 million votes in their 5 years of business. A standard database on a 1ghz machine and 7200 rpm drive can handle 1 million votes a day easy.
[ May 08, 2004: Message edited by: Brahim Bakayoko ]
 
hi ruben
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank very much!
I have just finish that voting system by using database, and it works fine!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!