AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   server performance on mysql connection accross other plugins (https://forums.alliedmods.net/showthread.php?t=341725)

bigdaddy424 02-08-2023 16:05

server performance on mysql connection accross other plugins
 
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?

deprale 02-13-2023 07:33

Re: server performance on mysql connection accross other plugins
 
why not just make one plugin that connects to the database and make the others send the info to that one?

Rohanlogs 02-19-2023 08:14

Re: server performance on mysql connection accross other plugins
 
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.

deprale 02-20-2023 23:05

Re: server performance on mysql connection accross other plugins
 
Quote:

Originally Posted by Rohanlogs (Post 2799839)
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).

ChillerX 02-20-2023 23:10

Re: server performance on mysql connection accross other plugins
 
Quote:

Originally Posted by deprale (Post 2799946)
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 :P I can`t help but to notice that any sql plugin does in fact cause lag.


All times are GMT -4. The time now is 10:12.

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