greatman / craftconomy3

A Economy plugin for Bukkit & Canary Recode!
GNU Lesser General Public License v3.0
36 stars 67 forks source link

CPU Spiking & CraftConomy #105

Open Fluxty opened 7 years ago

Fluxty commented 7 years ago

Plugin could maybe benefit from caching methods, causes massive lag spikes on populous servers. Thanks <3

http://i.imgur.com/62EGwvZ.png

http://i.imgur.com/IT5EZYx.png

Related issues: https://github.com/greatman/craftconomy3/issues/95 https://github.com/greatman/craftconomy3/issues/81 https://github.com/greatman/craftconomy3/issues/63 https://github.com/greatman/craftconomy3/issues/54

Phoenix616 commented 7 years ago

Implementing caching with an economy plugin that is supposed to not have any exploits is really difficult to do, especially in a time where you want economies to work on multiple servers connected to a Bungee network without balances desyncing.

My suggestion to you would be to put a faster database behind it.

Fluxty commented 7 years ago

@Phoenix616 In relation to a recent crash of our JVM:

"net.brcdev.shopgui" is using Vault to check the balance of a player in the main thread. Craftconomy3 ("com.greatmancode.craftconomy3") performs a database query in the main thread in response to the Vault API request.

I'd say Craftconomy is at fault for doing database queries in the main thread, it should cache player balances in memory.

EDIT: I do not use the DB to sync money across our network. Each server uses a separate DB. Optional caching?

Phoenix616 commented 7 years ago

@Fluxty Yeah, optional caching would be one way to work around a slow database. If the only queries that you are worried about happen very often and are only balance checks you could even let your database cache the result by itself.

Another one would be for plugins to not access an economy plugin on the main thread. (That could result in new desync-issues 'though as two threads might access the same account at the same time)