From 338aea42e66bc156efc1c6dc907395e1eb2b126d Mon Sep 17 00:00:00 2001 From: A248 Date: Wed, 1 Mar 2023 03:40:40 -0500 Subject: [PATCH] Documentation on query performance and address strictness (#190) Closes #190 and #192 --- bans-core/src/it/geyser-support/pom.xml | 4 +- docs/Database-Performance.md | 52 +++++++++++++++++++ docs/Guide-to-Composite-Punishments.md | 6 +-- ...t_-Lenient,-Normal,-and-Strict-settings.md | 19 +++++-- docs/_sidebar.md | 3 +- 5 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 docs/Database-Performance.md diff --git a/bans-core/src/it/geyser-support/pom.xml b/bans-core/src/it/geyser-support/pom.xml index 2f0b04aaa..607b3d749 100644 --- a/bans-core/src/it/geyser-support/pom.xml +++ b/bans-core/src/it/geyser-support/pom.xml @@ -100,7 +100,7 @@ opencollab-snapshot-repo - https://repo.opencollab.dev/snapshot/ + https://repo.opencollab.dev/maven-snapshots/ true @@ -109,4 +109,4 @@ - \ No newline at end of file + diff --git a/docs/Database-Performance.md b/docs/Database-Performance.md new file mode 100644 index 000000000..916b949e2 --- /dev/null +++ b/docs/Database-Performance.md @@ -0,0 +1,52 @@ + +LibertyBans' performance is strongly related to database query performance. Fast database access equates to fast plugin performance. + +This page is mostly useful for large servers looking to ensure efficient operation. + +### Performance Factors + +Performance largely depends on the database queries issued to check incoming players for bans and chatting players for mutes. Every time a player connects to the server, or sends a chat message, a database query is executed. If these queries take longer, connections and chat messages will become delayed. + +To reduce database queries issued for chat messages, LibertyBans uses a mute cache. This prevents players chatting frequently from overwhelming the database. The mute cache keeps track of players who recently chatted and whether they are muted. + +## Performance Configuration + +### Address Strictness + +The configured address strictness directly affects query performance. Scalability is the primary concern. If a query is scalable, its execution time will not depend on the quantity of data. For example, a scalable query should yield similar results on a database with 100 punishments as on a database with 100,000 punishments. + +Introducing the **Rule of Preservation of Scalability:** In LibertyBans' queries, *scalability* is usually preserved by choosing a stricter level. + * This point is crucial. It means that query performance is not dependent on the number of stored punishments. + * There is one exception to the Rule of Preservation of Scalability. Using the default HSQLDB database with `STERN` or `STRICT` eliminates scalability of enforcement queries, as investigated in [#190](https://github.com/A248/LibertyBans/issues/190). Large servers are therefore discouraged from using HSQLDB with either `STERN` or `STRICT` settings. + +Generally, progressively stricter address strictness options increase execution time. More computational work is necessary to fulfill a greater level of address strictness. However, thanks to the Rule of Preservation of Scalability, this slightly greater per-query execution cost is relatively non-consequential. + +### Connection Pool Size + +Following recommended technical practice, LibertyBans uses a fixed connection pool. By default, the connection pool is quite small with only 6 connections. + +You will likely be surprised to find that a pool of 6 connections can service a large server with many players connecting and chatting. For a large network with LibertyBans installed on the proxy, you may wish to increase the connection pool size. + +Please keep in mind that a larger connection pool does not necessarily mean better performance. Too often, administrators make pool sizes too large, which in fact reduces performance. Read [this page](https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing) to better understand connection pool sizing. + +### Mute Cache Settings + +Increasing the mute cache expiration time means mutes will be stored for longer, and therefore, fewer queries will be made to the database. + +The expiration semantic does affect performance, but it should be configured on the basis of correct behavior as priority. + +## Common Issues + +### Network Latency + +If your database is slow to respond, that will translate to LibertyBans taking longer to check bans and mutes. + +Ensure the database is not located in a geographically distant region (for example, a MySQL database in Antarctica). + +### Connection Pool Overload + +If you run a large network with LibertyBans installed on the proxy, the default connection pool size may be insufficient to meet your needs. If you repeatedly notice players taking too long to login or chat, try increasing the connection pool size. + +If you are familiar debugging, it is fairly easy to investigate connection pool load by using either live debugging tools or logging configuration to monitor connection pool events. + +Another solution to an overloaded connection pool is more aggressive mute caching. diff --git a/docs/Guide-to-Composite-Punishments.md b/docs/Guide-to-Composite-Punishments.md index eb3c3cec3..b3358a07a 100644 --- a/docs/Guide-to-Composite-Punishments.md +++ b/docs/Guide-to-Composite-Punishments.md @@ -18,9 +18,9 @@ You should be familiar with UUIDs and IP addresses, the relation of these to use With respect to enforcing punishments, a composite ban is much akin to an IP-ban. * Using LENIENT strictness, any user with the banned UUID or the banned address will be banned. * Composite bans are thus useful if you desire punishment stricter than a LENIENT IP ban, which bans only players with the address, but not as restricting as a NORMAL IP ban, which bans all players that have ever had that address. -* Using NORMAL or STRICT strictness, the applicable users are the same as if the ban was an IP ban. - * This is because, under NORMAL/STRICT strictness, an IP ban will always apply to the user who had that IP address, so it will be as if the user's UUID was banned too. - * Recall the explanations of [NORMAL and STRICT enforcement](Punishment-Enforcement_-Lenient,-Normal,-and-Strict-settings) +* Using NORMAL, STERN, or STRICT strictness, the applicable users are the same as if the ban was an IP ban. + * This is because, under STERN/NORMAL/STRICT strictness, an IP ban will always apply to the user who had that IP address, so it will be as if the user's UUID was banned too. + * Recall the explanations of [punishment enforcement](Punishment-Enforcement_-Lenient,-Normal,-and-Strict-settings) With respect to creating, undoing, and listing punishments with commands, composite bans are arguably easier to use than IP bans. * In punishment messages, composite victims are displayed as a username rather than an IP address. diff --git a/docs/Punishment-Enforcement_-Lenient,-Normal,-and-Strict-settings.md b/docs/Punishment-Enforcement_-Lenient,-Normal,-and-Strict-settings.md index 492d1d1d2..8f69d6569 100644 --- a/docs/Punishment-Enforcement_-Lenient,-Normal,-and-Strict-settings.md +++ b/docs/Punishment-Enforcement_-Lenient,-Normal,-and-Strict-settings.md @@ -1,15 +1,24 @@ -Here's how punishments are enforced. I'll use bans in this explanation, but the same can be said for mutes. +This page explains how punishments are enforced. I'll use bans as an example, but the same can be said for mutes. + +Punishment enforcement depends on the `address-strictness` setting you configure. + +## Choosing an Address Strictness + +The default address strictness is `NORMAL`. The behavior in other punishment plugins is similar to `LENIENT` in LibertyBans. + +For large servers, there are also [performance considerations](Database-Performance) to choosing the strictness. ## User Ban -The ban applies only to the target user. That user may change their name, but they will still be banned according to their UUID. +On lenient, normal, or stern address strictness: +* The ban applies only to the target user. That user may change their name, but they will still be banned according to their UUID. -## IP Bans +On strict strictness, user bans are treated as if IP bans. -How an IP ban is applied depends on the `address-strictness` you configure. +## IP Bans -Note that if "strict" is used, user bans are treated as if IP bans. +Behavior depends on the strictness configured. ### Lenient strictness diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 1d3780eb3..e7ae93bf1 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -14,9 +14,10 @@ * [Versioning and Support Policy](Versioning-and-Support-Policies) * [Upgrading 1.0.x -> 1.1.0](Upgrading-to-LibertyBans-1.1.0-from-1.0.x.md) + [Full changelog for 1.1.0](Changes-in-LibertyBans-1.1.0.md) * [Upgrading 0.8.x -> 1.0.0](Upgrading-to-LibertyBans-1.0.0-from-0.8.x) + [Full changelog for 1.0.0](Changes-in-LibertyBans-1.0.0) -* For Developers +* Technical * [Developer API](Developer-API) * [The Database Schema](The-Database-Schema) + * [Achieving High Performance](Database-Performance) * Relations to other software * [Importing from other plugins](Importing-from-Other-Plugins) * [Dealing with misbehaving plugins](Misbehaving-Plugins)