Re: what's better way to store a million keys in mem?
- From: Mark Space <markspace@xxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 15:35:03 GMT
Mark Space wrote:
dsjoblom@xxxxxx wrote:John_Woo wrote:Hi,
A application, needs to check whether a user already logined, by
looking at static var in memory.
I don't have good idea. what's doing is, use Hashmap <not sure
Hashtable is better interms of inserting/removing/finding> to store ID
<string> -- key and status <character> -- value.
question:
what the better way to implement this goal, it should support up to 1
million of keys, in terms of high inserting/removing/finding, and
happened more frequently.
If you *must* keep track of users by keeping user data in memory, this
is probably one of the quickest solutions. But it will eat up a lot of
memory.
And it won't be stored in memory anyway. Every system now-a-days uses virtual memory. Which means that memory that isn't used much is off-load to disk, and only loaded back when needed. So your data will be stored on disk anyway.
A database is a good idea. Maybe check out file locking as an alternative. For example, have a list of users and passwords in a file. Maybe call it /etc/passwd or something. Each time a user logs in, lock the first byte of his/her entry in the /etc/passwd file. This may take
Oops, John I think I got confuzzled with your previous post. Ignore the stuff about locking users. Everything else about one million users still applies I think, at least in principle.
Off the top of my head, I think the other way to do this is to write a very efficient program in C, then let Java talk to it over a socket or something..
Final thoughts: one million users is A LOT. I mean, REALLY A LOT. There are only 40,000 or so user ports on a Unix system with TCP/IP. Have you very carefully investigated the requirements of this system you are building? I'm starting to seem more than just "a database" or "use C." I think you'll need to build out some kind of load balancing array, and that's non-trivial. Even a couple thousand users logged in at any given time is going to stress out a single system greatly. Better think this through carefully if it's important...
- References:
- what's better way to store a million keys in mem?
- From: John_Woo
- Re: what's better way to store a million keys in mem?
- From: dsjoblom
- Re: what's better way to store a million keys in mem?
- From: Mark Space
- what's better way to store a million keys in mem?
- Prev by Date: Re: What is SOA?
- Next by Date: importing package in eclipse plug in
- Previous by thread: Re: what's better way to store a million keys in mem?
- Next by thread: Re: what's better way to store a million keys in mem?
- Index(es):
Relevant Pages
|