Solved BungeeCord Network - Best way to manage data

Discussion in 'Spigot Plugin Development' started by SmokingIsBadMkay, May 5, 2017.

  1. Hello Spigoters,
    I'm currently reviewing my backend and I'm pretty sure there are better ways to manage my data.

    This is how I currently save my data:
    When a player joins (a spigot server) I load their data from mysql into the Local PlayerData class. There is a 3 second delay before the data loads onJoin because of the time it takes to save it when players go to another bungeecord server. Once a player leaves the data gets saved to the Mysql database again.

    Now I'm thinking about (somehow doing the following):
    When a player joins the proxy load their data from mysql onto some cache server which can be accessed from all spigot servers and the bungeecord server (plugins). Then all plugins would get/set the data from/on the cache server. When a player leaves their cached data would be saved in the Mysql server again.

    I've been doing some research and I found out about Redis, but I'm not sure if you're able to do this with Redis and if so how? You can only save Strings using Redis right?

    If you have any suggestions let me know.
    Thanks a lot!
     
  2. Bungee plugin messaging channel.

    This "cache server" would be a bungeecord plugin, implementing a PluginMessagingChannel on a new subchannel.
    These would be spigot plugins, implementing a PluginMessagingChannel on the same subchannel like above.
    The wiki link above showes the bungeecord system subchannel called "BungeeCord". But you can use any custom subchannel by your own.
     
  3. You could do that with SocketServers as well. But you need to code it yourself.
     
  4. Maybe I haven't completely understood the question, but I think he has multiple proxies and the proxy loads/saves the data of every player.
     
  5. I understood it differently, sounds like he has some data on the bungeecord server, which saves it into a MySQL database and want to acess it on every spigot server. But i'm not sure, either.
     
  6. If you have 1 proxy: Cache the data with guava (https://github.com/google/guava/wiki/CachesExplained) and send it to the spigot server over a plugin messaging channel

    If you have multiple proxies:
    Build a custom server with http://netty.io/ or http://vertx.io/, cache the data with guava https://github.com/google/guava and send it to the spigot server.​
    or
    Use something like https://memcached.org/ in combination with your DB​
     
    • Useful Useful x 1
  7. I only have one proxy, but I want to find the best way to get/set data from bungee and the spigot servers.
     
  8. I understand I have to code it myself lol.
     
  9. Is there a way to have a cache server (I think you can do that with Redis) and then all all plugins will load and set data from/on there?
     
  10. I understand the messaging channel but I've always had trouble sending plugin messages from the Spigot servers, only managed to send the from bungee.
     
  11.  
  12. Going to take a look at that, thanks. Just saw that post. :)
     
  13. Not marking thread as solved yet since I may get some other good suggestions, but the suggestions so far were great, thanks!
     
    • Agree Agree x 1
  14. Redis would work well in this situation, it's extremely fast and will prevent needing to send multiple SQL queries each time a player switches server. Here's how I'd do it:

    Player Joins -> If not in redis cache, fetch from SQL -> Save to cache -> Player Leaves proxy -> Queue for SQL push.
     
    • Agree Agree x 1
    • Useful Useful x 1
    • Useful Useful x 2
  15. When I lacked Redis capabilities (long story short, owner didn't want to use it), I ended up loading everything centrally through a bungeecord plugin and coded a netty client/server model to transfer data using JSON (still use it, but feel it's not the most optimal system). Honestly, I'm a fan of redis for this matter.
     
    • Informative Informative x 1
  16. Okay thats cool, will use Redis then. Gonna watch some tutorials ;). If anyone has any other ideas let me know.

    Thanks a lot!
     
    • Agree Agree x 1
    • Like Like x 1