Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashMap performance and reliability

 
Tim Shkembi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Since database not an option i need to know if the Java Hash Map would hold reliably a couple of million objects and what server configuration that would need?
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings Tim..

That would all depend on the size (internally) of each object in your HashMap.

Performance in memory should be okay, again depending on your infrastructure.

For a million entries though, I would look at distribute caching across multiple nodes.
Especially if you're in a HA environment, and cannot afford the VM/app server to crash.

WP
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, provided you have enough memory then it will hold those objects reliably.

However I don't understand what you mean by "server configuration" in your question. As far as I can see from your stated requirements (store objects, not in a database) all you need to do is to provide enough memory.
 
Tim Shkembi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Appreciate your comments. It is running fine so far after we increased the memory on the server. That's what I meant by configuration on the server.
The Hashmap is created only once by reading a Flat file and it will be recreated in case no reference to it.
Just wonder if the Hashhmap will keep the 2 million Objects Intact in the long run ?
Forgot to tell you that Objects are of the same datatype and have 7 strings with only getters.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're asking if objects are going to disappear mysteriously from the HashMap with no action on your part, then no. Of course not.
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Shkembi wrote:Appreciate your comments. It is running fine so far after we increased the memory on the server. That's what I meant by configuration on the server.
The Hashmap is created only once by reading a Flat file and it will be recreated in case no reference to it.

Not quite sure what that last bit means, but whatever.

A few issues I can see with this approach:
1. Start-up time. Something, somewhere, has to read and load those 2 million objects; and anything that wants to use your internal HashMap will have to wait until it does.
2. Does your application update any of these values? If so, as the song goes: "There may be troubles ahead..." and you won't be dancing when you have to face the music.

Databases really are very easy these days. In fact, JavaDB (or whatever it's called now) content can be shipped right along with your jar. If it was 200 items I might say don't bother; but 2 million?

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic