Raised This Month: $51 Target: $400
 12% 

server performance on mysql connection accross other plugins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 02-08-2023 , 16:05   server performance on mysql connection accross other plugins
Reply With Quote #1

If I have multiple plugins(around 10) using the same MySQL database, will it perform better if they all ran in a single plugin since now only connects once to the same data server?
__________________
bigdaddy424 is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 02-13-2023 , 07:33   Re: server performance on mysql connection accross other plugins
Reply With Quote #2

why not just make one plugin that connects to the database and make the others send the info to that one?
__________________
deprale is offline
Rohanlogs
Senior Member
Join Date: Nov 2015
Old 02-19-2023 , 08:14   Re: server performance on mysql connection accross other plugins
Reply With Quote #3

Yes, I think it would be smarter to have 1 plugin handle the queries.
However it could be a rather tiresome coding task if you have many plugins with a lot of functions and variables, to have them all communicate to a single plugin.

Idk if the improvement would be that dramatic, but I noticed a long time ago when using the sqlx library on many plugins to save data on mapchange, even with threaded queries, it caused heavy lag/small crash everytime the map changed, making the loading screen like 4x longer.

I solved this lag by hooking a function X seconds before mapchange to save players stats.
I made some variation on each plugin when to execute the save so they don't all execute at once.
This completely fixed the laggy loading screen when the map changed.
If you do something like this you need to add a check on client_disconnect if the players stats are already saved, to not save them again.

This of course may cause some "lost" stats, for example if you are tracking player kills, and a player kills someone during the last second after the save queries were already called, that kill would not be saved.
But in my case it was well worth it to fix the lag/crash of the loading screen.
__________________
Rohanlogs is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 02-20-2023 , 23:05   Re: server performance on mysql connection accross other plugins
Reply With Quote #4

Quote:
Originally Posted by Rohanlogs View Post
Yes, I think it would be smarter to have 1 plugin handle the queries.
However it could be a rather tiresome coding task if you have many plugins with a lot of functions and variables, to have them all communicate to a single plugin.

Idk if the improvement would be that dramatic, but I noticed a long time ago when using the sqlx library on many plugins to save data on mapchange, even with threaded queries, it caused heavy lag/small crash everytime the map changed, making the loading screen like 4x longer.

I solved this lag by hooking a function X seconds before mapchange to save players stats.
I made some variation on each plugin when to execute the save so they don't all execute at once.
This completely fixed the laggy loading screen when the map changed.
If you do something like this you need to add a check on client_disconnect if the players stats are already saved, to not save them again.

This of course may cause some "lost" stats, for example if you are tracking player kills, and a player kills someone during the last second after the save queries were already called, that kill would not be saved.
But in my case it was well worth it to fix the lag/crash of the loading screen.
I fixed this by completely just not using mysql at all, but rather communicate with my mongodb through a crud api, with amxxeasyhttp, i can do all queries whenever and it won't lag the server or hang the thread (sql would do that even when using threaded tuples).
__________________
deprale is offline
ChillerX
Member
Join Date: Dec 2022
Old 02-20-2023 , 23:10   Re: server performance on mysql connection accross other plugins
Reply With Quote #5

Quote:
Originally Posted by deprale View Post
I fixed this by completely just not using mysql at all, but rather communicate with my mongodb through a crud api, with amxxeasyhttp, i can do all queries whenever and it won't lag the server or hang the thread (sql would do that even when using threaded tuples).
A tutorial would be nice I can`t help but to notice that any sql plugin does in fact cause lag.
ChillerX is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode