SA-MP Forums Archive
Lag Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Lag Problem (/showthread.php?tid=563200)



Lag Problem - jawiie - 14.02.2015

Hey, i have lag problem in my server.
CPU Usage %2~5 and i got 1gb free ram still. Is it because of network connection?
btw i use ******' timers instead of settimer.


Re: Lag Problem - Nixco - 14.02.2015

Can we take a look at your OnPlayerUpdate callback?


Re: Lag Problem - jawiie - 14.02.2015

Sorry im mobile now

In PlayerUpdate

Calculating vehicle speed
Checking for teleport/airbr. hack
Calculating Fuel
Checking Weapon Hack
Total km counter etc.

Sometimes we play with 65 players nolag, sometimes we play with 2-5 players laggy


Re: Lag Problem - LinuxViper - 14.02.2015

May be it's a silent DDoS.

Try to buy a Gameserver host for your SA-MP server it's better then SA-MP on VPS.


Re: Lag Problem - NoSoap - 14.02.2015

What is your network allowance/speed?

How is your MySQL connected?


Re: Lag Problem - jawiie - 14.02.2015

100mbit shared network, im using mysql at localhost, i store most data at arrays to avoid mysql traffic


Re: Lag Problem - CalvinC - 14.02.2015

This can be caused by many different things, huge inefficient saving systems, too many timers, using OnPlayerUpdate or big/infinite loops.


Re: Lag Problem - Nixco - 14.02.2015

Quote:
Originally Posted by jawiie
Посмотреть сообщение
Sorry im mobile now

In PlayerUpdate

Calculating vehicle speed
Checking for teleport/airbr. hack
Calculating Fuel
Checking Weapon Hack
Total km counter etc.

Sometimes we play with 65 players nolag, sometimes we play with 2-5 players laggy
Well, it is advised to use the least number of code in OnPlayerUpdate to avoid any mess and/or lag spikes. Seemingly, you're using y_timers which would be very effective if you add the code that you have on OnPlayerUpdate to an existing timer you have created to a short-time-interval.

It might not be the main source of lag, but it could help to minimize it as possible. Also, are you sure you're not being DDoSed?

Are you using something like:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
for your loops? Try minimizing your loops as much as you can unless you're confident they don't hurt - try foreach.inc?


Re: Lag Problem - jawiie - 14.02.2015

Quote:
Originally Posted by Nixco
Посмотреть сообщение
Well, it is advised to use the least number of code in OnPlayerUpdate to avoid any mess and/or lag spikes. Seemingly, you're using y_timers which would be very effective if you add the code that you have on OnPlayerUpdate to an existing timer you have created to a short-time-interval.

It might not be the main source of lag, but it could help to minimize it as possible. Also, are you sure you're not being DDoSed?

Are you using something like:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
for your loops? Try minimizing your loops as much as you can unless you're confident they don't hurt - try foreach.inc?
to slow down the function calls in onplayerupdate i used counter that trigger functions every 5 callback is it bad? while while server lagging, remote desktop connection stucks? could it be ddos?


Re: Lag Problem - rymax99 - 15.02.2015

Quote:
Originally Posted by LinuxViper
Посмотреть сообщение
May be it's a silent DDoS.

Try to buy a Gameserver host for your SA-MP server it's better then SA-MP on VPS.
That's unlikely.

If you'd like to provide evidence or reasoning for your second point, feel free. Other than the minimum amount of overhead on a proper, well configured hypervisor, you shouldn't have any issues running SA-MP on a virtual server. If you run it on a $3 server that is 'too good to be true' such as OVH's VPS offerings, expect issues.