Search code examples
javamysqlxmppderby

tables in Ram or DB tables, for best performances


I am programming a server application (chat server side) with java, which receive requests and send to a target.

  1. I have several tables in the database, and when the server application starts, I programmed it to copy all the content of the database to Map tables (in the ram) in order to speed up the pull
    • push data while the application running. Dose this correct way? Or you suggest me to pull data from the database directly when I need a detail. and remove the Map<> tables from the ram!?
  2. I suffer from memory leak.
  3. Does dealing with the database slows the application?

Solution

  • Whether caching all or some of the data in memory makes sense depends on your use case. It can improve performance but it adds complexity which might not be needed.

    You can load millions or even billions of records into a JVM, but much more then this you need an off heap storage such as a data store for this purpose or a database. Using off heap memory, you can have trillions of records in a JVM but this is rarely needed.