Jump to content

Delay for chat messages


srslyyyy

Recommended Posts

  • Scripting Moderators

Hi. I was about to create a log system for myself, instead of using default outputServerLog. And here's my question, how much delay between logging i should use, since file functions are slow and i am worried about server performance. I have 40 slots server, 1.5 second should be enough?

Link to comment
  • Moderators

@majqq

There is a buffer, it will only start writing when the buffer reached an amount of data it will start writing. So by default it should be fine. Just what are you going to log? That is the real question.

 

Slots do not tell you how much performance your server has. In some cases I would even consider slots a scam, as the player count is just a performance-usage multiplier X the resources. But there should be a few good deals out there... at least I hope so.

The thing that matter:

  • CPU
  • RAM (1GB should be enough but better to have 2 in case of a memory leak)
  • SWAP (when you run out of ram, you will be using your storage as ram, this is called SWAP. It is very slow.)
  • Storage (SSD recommended, especially when you are not having enough RAM while doing heavy workloads) You do not need a lot of storage for MTA.
  • With how many other clients are using the server.
  • Network speed and bandwidth.

 

Edited by IIYAMA
  • Like 1
Link to comment
  • Scripting Moderators
2 hours ago, IIYAMA said:

@majqq

There is a buffer, it will only start writing when the buffer reached an amount of data it will start writing. So by default it should be fine. Just what are you going to log? That is the real question.

 

Slots do not tell you how much performance your server has. In some cases I would even consider slots a scam, as the player count is just a performance-usage multiplier X the resources. But there should be a few good deals out there... at least I hope so.

The thing that matter:

  • CPU
  • RAM (1GB should be enough but better to have 2 in case of a memory leak)
  • SWAP (when you run out of ram, you will be using your storage as ram, this is called SWAP. It is very slow.)
  • Storage (SSD recommended, especially when you are not having enough RAM while doing heavy workloads) You do not need a lot of storage for MTA.
  • With how many other clients are using the server.
  • Network speed and bandwidth.

 

You mean `buffer` like in case of sending triggers? I guess a solution will be saving this in table, and later writing to file. I am going to log some more than just logs from player messages on chat, but this will be one and only thing which was i worried about due to the frequency of sending them. I have 4GB RAM, about memory leak i'm familiar with it if we're talking about tables (https://wiki.multitheftauto.com/wiki/Debugging) - correct me if i am misunderstooding definitions.

Link to comment
  • Moderators
3 minutes ago, majqq said:

You mean `buffer` like in case of sending triggers? I guess a solution will be saving this in table, and later writing to file. I am going to log some more than just logs from player messages on chat, but this will be one and only thing which was i worried about due to the frequency of sending them. I have 4GB RAM, about memory leak i'm familiar with it if we're talking about tables (https://wiki.multitheftauto.com/wiki/Debugging) - correct me if i am misunderstooding definitions.

No, I mean in this case a RAM buffer. As in waiting for enough data before processing it. This indeed is also something which can be compared to a network buffers, but I was not talking about that in my last reply. I was talking about how your server is writing logs intern.

 

If you are going to collect player debug information and send it to the server. Then yes you might very well consider using a buffer for preventing the network from being overloaded.

A latent event will make sure the messages will not block your regular output. (even though it can still happen if there is too much going on)

https://wiki.multitheftauto.com/wiki/TriggerLatentServerEvent

https://wiki.multitheftauto.com/wiki/GetLatentEventStatus

 

 

 

 

  • Like 1
Link to comment
  • Scripting Moderators
5 hours ago, IIYAMA said:

No, I mean in this case a RAM buffer. As in waiting for enough data before processing it. This indeed is also something which can be compared to a network buffers, but I was not talking about that in my last reply. I was talking about how your server is writing logs intern.

 

If you are going to collect player debug information and send it to the server. Then yes you might very well consider using a buffer for preventing the network from being overloaded.

A latent event will make sure the messages will not block your regular output. (even though it can still happen if there is too much going on)

https://wiki.multitheftauto.com/wiki/TriggerLatentServerEvent

https://wiki.multitheftauto.com/wiki/GetLatentEventStatus

 

 

 

 

To be more clear - only player messages on chat, and some logs from my custom admin panel script. About slots i mean that if more players on server, then more messages can appear at the one moment. So as i said above, 1.5 sec delay between message per player, and `buffer` for 5-10 messages, if table reach that limit, log them to file. Should be alright?

Link to comment
  • Moderators

@majqq

A 1.5sec delay between chat messages, is not very user friendly. It better to accept messages with a burst rate. Because sometimes you wrote something, but it is not complete or incorrect.

 

 

There are 3 things you can do to make it more user friendly. (And spammers user unfriendly)

1.

Each message has a message rate value of 1.

When the rate value becomes greater than 3. Disable the input. Each message represents 500ms. So in total you have 1500ms of burst power.

  • So you can send 3 messages after each other without delay.
  • The messages rate value will decrease with 1, every 500ms. (So +1 message every 500ms)
  • Before you have your 3 burst messages back, it will take 1.5sec.

 

2.

After writing your first message, you wait 400ms.

Every message that is typed within that 400ms is included in your first trigger.

Then the 400ms timer is over and you push all the messages that have been written within that timelimit.

(which is just another buffer)

 

3

Warn people when spamming.

(warn the user 1 time, but still send the message)

After the warning and still spamming > Punish people when spamming.

Mute for X amount of time.

Note: Do not disable the input, because if somebody is using macro's/bingkeys or something like that, you need to punish them extra hard. Every time they spam when muted. Multiply the mute time by 1.2. (of the previous +20% mute time, which becomes even more punishing over time)

60 sec > 72 sec > 86,4 sec > 103,68 sec > 124,42 sec > 149,30 sec

 

 

On the server

You also also need a buffer. This is just a timer that waits for an amount of ms when there is input.

 

- New message

- Start buffer timer. (0.5s)

- New message

- New message

- New message etc.

- Buffer timer is over. > Send messages to the other clients.

 

 

 

 

 

Edited by IIYAMA
  • Like 1
Link to comment
  • 4 weeks later...
  • Scripting Moderators

Hi, @IIYAMA

I've already created buffer for log system, to reduce impact on server. After reaching x messages it saves everything to file and clears table. Also in case of resource restart, when buffer < max size, to not lost anything that was in table, i've done saving it on resource stop. And here comes question, is there any chance that it would fail? For example if there will be a lot of data in table (not my case, though).

Edited by majqq
Link to comment
  • Moderators
1 hour ago, majqq said:

Hi, @IIYAMA

I've already created buffer for log system, to reduce impact on server. After reaching x messages it saves everything to file and clears table. Also in case of resource restart, when buffer < max size, to not lost anything that was in table, i've done saving it on resource stop. And here comes question, is there any chance that it would fail? For example if there will be a lot of data in table (not my case, though).

Sure there is any chance of fail. For example an application or server crash. But atleast you know that it didn't happen because your database was too busy writing every single update to the storage.

  • Like 1
Link to comment
  • Scripting Moderators
2 hours ago, IIYAMA said:

Sure there is any chance of fail. For example an application or server crash. But atleast you know that it didn't happen because your database was too busy writing every single update to the storage.

But excluding those, everything should be alright? I was worried about such situation (i don't really know what's happening when resource stops) for example: there's a lot of data to save, and resource saves few files (yet, not my case), JSON, sqlite3 database. Unloading code follows before/after or together with functions which are executed at resource stop?

  • Like 1
Link to comment
  • Moderators
7 hours ago, majqq said:

But excluding those, everything should be alright? I was worried about such situation (i don't really know what's happening when resource stops) for example: there's a lot of data to save, and resource saves few files (yet, not my case), JSON, sqlite3 database. Unloading code follows before/after or together with functions which are executed at resource stop?

One thing you might have to take in to consideration is that the resource might take too long to save a large buffer.

 Especially when onResourceStop is triggered. The resource wants to stop, but it can't because too much is going on. Don't end up with a too large buffer, because the server might want to kill the resource process. (warning: resource xxx takes too long to stop...)

Shouldn't be required > Just to be safe, add a flush feature which will write the buffer in to the db, which you can use before making a attempt to stop the resource. Then you are at least prepared for...

 

 

 

Edited by IIYAMA
  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...