Will my server lag?

Discussion in 'Plugin Development' started by kevin3220, Nov 8, 2013.

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

    kevin3220

    Will my server lag very much if i set scheduleSyncRepeatingTask every 1 second?

    Thank you ;)
     
  2. Offline

    1Rogue

    yes.
     
  3. Offline

    Wolvereness Bukkit Team Member

    Many plugins have tasks that run every tick (20 times per second). The only reason your server will lag by doing so is if your task takes a long time to run.

    Perform <100 block changes & send chat messages? No lag.

    Perform >100,000 block changes & calculate the traveling salesmen problem for all players? Major lag.
     
    Hoolean likes this.
  4. Offline

    kevin3220

    1Rogue Wolvereness
    What i need to do is to add 10 dollars to every online player. And put their name and balance to HashMap and save it to textfile. Is it too much?
     
  5. Offline

    The_Doctor_123

    kevin3220
    Too much disk power involved there. Maybe have a repeating task that saves it every 5 minutes and on shutdown?
     
  6. Offline

    kevin3220

    Do you think 5 is ok?
     
  7. Offline

    The_Doctor_123

    kevin3220
    Yeah, 5 minutes is perfectly fine.
     
  8. Offline

    kevin3220

    Thats too big interval for my plugin ;(
     
  9. Offline

    The_Doctor_123

  10. Offline

    maxben34

    5 Minutes isn't that long? 300*20...
     
  11. Offline

    kevin3220

    Well you see, i need to update players money immediately
     
  12. Offline

    1Rogue


    Then update the hashmap in 1-second intervals and then save on a 5-minute interval

    Thought I'm not sure why you're just giving $10 a second for no reason.
     
  13. Offline

    CubieX

    Update it in your HashMap whenever you need it.
    But only store it to the text file every couple minutes, to prevent frequent disk operations.
     
  14. Offline

    kevin3220

    well thats a good ide. But how do i do 2 tasks different time?
     
  15. Offline

    The_Doctor_123

    kevin3220
    The same way you create one. Just register two tasks.
     
  16. Offline

    hellboyPS

    Just save it to disc asynchronously.
     
  17. Honesty, technically in a way everything causes the server to lag a bit :p Anyways, the best thing to do is to save it to memory, using getConfig(), an ArrayList, or a HashMap, and then saving it to disk on shutdown, or every 5 to 10 minutes.
     
  18. Offline

    kevin3220

    But what if i only update players money every 1 second and not adding 10 dollars. Just updating?
     
  19. Offline

    kevin3220

Thread Status:
Not open for further replies.

Share This Page