2

I've built a multi threaded messaging application in C and I'm currently using a MySQL Memory table to save the session ID, but I'm not sure whether this was a good decision or not.

It works like this, the application sends a message and saves the source session ID in the MySQL table. When the application gets the success response it will remove the session's ID from the MySQL table, or if it received an error response then it will keep the ID to be retried later.

I've built it this way so that I don't need to care about building a data structure by myself, and the Database provides flexibility when it comes to querying it.

Do you think this is appropriate or do I need to use something else? Please note that the application is expecting to handle a large number of transactions/sec.

  • Is this a single user application? What if the system crashes - How would you be able to restore the session state? Do you care? – NoChance Mar 26 '12 at 1:12
  • two or more process are gonna be running on the system – poly Mar 26 '12 at 1:20
3

If you can fit everything into available memory why not use one of the many Hash map libraries/templates available for C/C++.

You will get a massive performance boost (no disks, no IO, no parsing no .....) and most of the APIs available are pretty simple to use.

Have a look at this comparison to see which one would best suit your needs.

0

I can share what we did to solve this problem. We built a write-ahead-log, and used an in-memory black/red tree for lookup on a very large set of keys.

The benefits of doing this yourself are many... Encapsulation, less dependencies, performance, no network overhead, etc.

0

You can instead use NDB engine to improve performance and concurrency. High performance replacement of the MySQL Memory storage engine with NDB

  • would you mind explaining more on what it does and why do you recommend it as answering the question asked? "Link-only answers" are not quite welcome at Stack Exchange – gnat Sep 21 '13 at 11:20
0

If the application is expecting to handle a large number of transactions and the only purpose of the code is processing the session ID, I would suggest you to use hash table. MySQL is so heavy in this situation. In addition, users should install MySQL first when they want to use your application, this will impair your application's user-friendly feature.

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.