• Timers causing server fps drops?
    10 replies, posted
I'm currently toying around with an addon that I've made, it works perfectly at first... however after about an hour to two hours it drops the server FPS down to 10. This addon uses a Simple timer that keeps repeating every 0.3 seconds, would this cause the above mentioned issue? If so, could anyone suggest an alternative to using timers so I could at least test that out? [editline]26th November 2010[/editline] Its sort of a realtime database application using MySQLOO.
Code?
[lua] function UpdateDB() local dbUpdate = db:query("SELECT * FROM Edit WHERE server = 2;") --dbUpdate.onData = function() end dbUpdate.onFailure = function() print("Edit: Error") end dbUpdate.onError = function(error_message) print(error_message) print("ERROR") end dbUpdate.onSuccess = function() print("Success") local Data = dbUpdate:getData() local Edit = Data[1].Edit local Edit = Data[1].Edit local Edit = tostring("("..Data[1].server..") ") if (DB_Edit ~= DB_Edit) then DB_Edit = Edit local R = Data[1].clR local G = Data[1].clG local B = Data[1].clB local Players = player.GetAll() for i = 1, table.Count(Players) do local ply = Players[i] end timer.Simple( 0.3, UpdateDB ) else timer.Simple( 0.3, UpdateDB ) end end dbUpdate.onFailure = function() print("Error Printing Query!") end dbUpdate.onError = function(error_message) print(error_message) print("ERROR ON UPDATE, CONNECTION LOST?") end dbUpdate:start() end -- end updateDB() [/lua]
Are you actually executing a query every 0.3 seconds? Plus, you are looping through the player's table (in a very odd way I might say). So I am going to say yes, it might have a bit of an impact on the performance.
[QUOTE=_nonSENSE;26308574]Are you actually executing a query every 0.3 seconds? Plus, you are looping through the player's table (in a very odd way I might say). So I am going to say yes, it might have a bit of an impact on the performance.[/QUOTE] Yes, Howso, and I changed the timer, and the second part of the orginal question? I changed the timer to 1 second it still reduced server fps but took about twice as long to do it.
Do you need to query every few seconds? It seems a bit redundant, and is generally a bad idea.
Yes, need to Query as close to realtime as possible, the query on average takes less than 0.01 seconds to complete.
And why do you need to query that often? [editline]26th November 2010[/editline] He added me on Steam. It's for a cross-server chat script. I suggested sockets, but can't remember the name of the best module (The only one I found was some shittily coded re-write)
Still, why would you need to do it that often? Couldn't you just do it when someone tries to send a message between the servers? also, whats with this? It seems very redundant. [lua]local Edit = Data[1].Edit local Edit = Data[1].Edit local Edit = tostring("("..Data[1].server..") ")[/lua]
Its edited sql db names and if you have a way to check if someone on another server sent a message im all ears
Sorry, wasn't thinking there about you having to check the db.
Sorry, you need to Log In to post a reply to this thread.