MySQL Lagging server

Discussion in 'Plugin Development' started by Reteckz, Mar 28, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Reteckz

    Hello,

    I made my own plugin, which gets the database info online-time from logblock at a mysql database, and converts it to hours played when you use the command /playtime ingame.

    The problem is: When I use this command, it lags the server for a few seconds before giving the result, and when I keep spamming the command, it puts the server offline for a few seconds.

    Logblock itself also selects information from the database, and shows it to you, like placed blocks, but it doesn't cause lag.

    So my question is: How to select information from MySQL via java without getting it to lag 2+ seconds?

    If you want my code send me a pm.
     
  2. Offline

    Ivan

    Cache the data on your server and use an asynchronous thread to load the data every 1-10 minutes. With caching I mean, create a HashMap with all the data, put all the data into that hashmap by using an async thread and just grab the data from that hashmap. There can occur some issues tho since this isn't thread safe at all.
     
  3. Offline

    Tirelessly

    Use a ConcurrentHashmap to avoid synchronization issues.
     
Thread Status:
Not open for further replies.

Share This Page