PDA

View Full Version : Server lag [LIBCOD]



maxdamage99
15th October 2015, 18:32
I use a script to save the statistics in the database (mysql):


Endmap()
{
players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
players[i] database_save();
wait 0.25; //without, lags so much that the card does not end
}
}
database_save()
{
sql_zapros="UPDATE `base_rank_players` SET `rank`='"+self.data["rank"]+"', `kills`='"+self.data["kills"]+"' WHERE `login_player`='"+self.accdata["login"]+"'";
mysql_query(level.db["mysql"], sql_zapros);
}

The data is saved, but if the number of players is greater than 5 server lag.
Characteristics my VDS:
RAM: 1024 (Indications at 10 players and change maps: 204/1024)
Proccesor Core's: 2 (2.8 + 2.8 Mhz); Ubuntu-14.04-x86_64-minimal
//////
Could it be due to libcod?????

IzNoGoD
15th October 2015, 23:22
answer: yes.
solution: http://killtube.org/showthread.php?1883-Asynchronous-mysql-queries

maxdamage99
16th October 2015, 13:43
You mean to keep everything in one common request ??

maxdamage99
16th October 2015, 13:46
mysql_async_create_query
mysql_async_create_query_nosave
mysql_async_getdone_list
mysql_async_getresult_and_free
mysql_async_initializer

Whether it is possible to carry out not using:http://killtube.org/showthread.php?1...-mysql-queries and using these features!
I am a bit do not understand (Write an example using my code) I will be very, very, very etc. Grateful to

IzNoGoD
16th October 2015, 17:16
There IS an example function in that thread. If you dont understand that, you shouldnt be trying to program asynchronously.

maxdamage99
16th October 2015, 17:31
I need to create a connection?


mysql_async_initializer(host, user, pass, db, port, 4); //???

IzNoGoD
16th October 2015, 17:45
Have you even read the code?

maxdamage99
17th October 2015, 09:26
Izno, look.


Endmap()
{
players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
players[i] database_save();
}
}
database_save()
{
sql_zapros="UPDATE `base_rank_players` SET `rank`='"+self.data["rank"]+"', `kills`='"+self.data["kills"]+"' WHERE `login_player`='"+self.accdata["login"]+"'";
mysql_async_create_query(sql_zapros);
}

so necessary?