1

I'm building an multi processes application and I need to save session ID, the sessions ID is 32 bit, and of course it can't be used twice in its lifetime, I'm currently using DB that saves all the ID in a table, and I do the following,

ID table is (int key, char used(1)) //1 is used, 0 is not 1. lock table 2. get one key for one sessions 3. update used field in it to used 4. unlock

After the session is finished the process use below to free key, 1. lock table 2. update used field in it to not used 4. unlock

I'm really wondering whether this is a good/fast implementation. and please note it's multi processes application.

1

Did you try memcached? It's fast, it has atomic updates, it does not have all the rest of database overhead. Not as fast as raw shared memory, but probably session registration is not your bottleneck anyway?

0

By definition database access is no the fastest repository. I need more details about the process to tell you something more useful, but keep in mind that using a database to do what you want is the simplest way but not the fastest. This link shows how Voltdb generates its unique transaction ID in a distributed environment : http://voltdb.com/company/blog/lifecycle-transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.