Commit Graph
955 Commits
Author SHA1 Message Date
Mike Hillyer 3c446748aa Forgot to add Scaling page to the TOC. 2024-10-03 10:52:25 -04:00
Wez Furlong 379d8aebbd fixup shrinking during low memory
Two issues here:

1. The maintainer would repeatedly try to shrink the ready queue
   each time it woke up during a low memory condition.  This has
   been fixed to trigger whenever we transition to low memory
   instead.

2. At some point during refactoring, we dropped the save part
   of the message shrinking processing, so we'd only successfully
   shrink messages that had previously been saved and stored to
   spool.  Messages that we deferred spooling, or otherwise modified
   post reception, would not be saved and thus not be eligible to
   shrink.

Ideally we'd have an integration test for this, but it is a bit awkward
because we'd need to contrive an appropriate ulimit for just this
instance and generate appropriate load to trip over that limit.  I don't
fancy the chances that such a test wouldn't be flakey.

My ad-hoc test procedure was:

ulimit -m 2028527
./target/release/kumod  --policy simple_policy.lua

then in another window:

./target/release/traffic-gen --target 127.0.0.1:2025 --body-size 100000 --duration 3600 --throttle 15000/s --http

the generator will eventially experience load shedding http responses,
and you can see the shrink procedure triggering in the kumod output.

curl -s 'http://127.0.0.1:8000/metrics' | grep memory

can also be used to check the usage, limit and how many times it trips.

You can also use smtp for this, but the smtp client in traffic gen will
try hard to reconnect without telling you about the shortage, so you
will need to look at the metrics to see it happening.
2024-10-02 14:49:28 -07:00
Wez Furlong d31c0f2dfc shaping: allow granular control of how checks are reported
At the lower level, expose an options struct that allows control
over how various checks and conditions are reported out of the
attempt to load the set of shaping files.

Expose a separate list of errors, distinct from warnings.

Each check can either be ignored, a warning, or an error.

Errors cause validate-shaping and --validate mode to exit
with an error condition, whilst warnings are simply emitted
as informational items.

In the shaping helper, it is possible to configure a separate set of
options for the main live service and validation mode, which allows you
to run a more relaxed configuration by default, but be a bit more strict
in your pre-commit and pre-deploy configuration validation pipeline

refs: https://github.com/KumoCorp/kumomta/issues/287
2024-10-02 10:12:42 -07:00
Wez Furlong d704677e2d fixup suspension handling for scheduled queues
This commit addresses a couple of related issues around scheduled qeueue
suspensions:

1. There was no check in the ready queue logic to confirm that a
   given message was not part of a suspension.  Ideally, it wouldn't
   land in the ready queue if it is suspended, but if you have a large
   ready queue and one of the messages generates a suspension, then
   the remainder would get attempted, oblivious to the new suspension.
   The resolution here is to add a check for that case, log a transfail
   and requeue the message.

2. We only checked whether the scheduled queue was suspended in the
   case where a message was being newly inserted into the queuing
   system.  Importantly, messages being promoted from the scheduled
   queue didn't use this code path.  This commit fixes this up by
   relocating the check to the appropriate location.  In addition,
   we now will log a transfail for this case and delay the message
   according to its retry schedule.

3. Since we're in here changing the retry schedule for suspensions,
   take the opportunity to take care of #293 which applies to the
   more general logic around all sources being suspended.

The upshot of this is that we're now logging transfails in a number
of suspension cases where we weren't previously, and using the normal
retry schedule for those cases where we weren't previously doing
that either.

refs: https://github.com/KumoCorp/kumomta/issues/290
refs: https://github.com/KumoCorp/kumomta/issues/293
2024-09-30 14:24:46 -07:00
Wez Furlong 0a248f5c53 logging: improve handling for small segment sizes
* When using very small file size or duration constraints, we might
  attempt to create multiple file segments in the same second.  Since
  we require exclusive creation access to the log file name, the
  subsequent attempts to open the segment would fail with a permission
  denied error and cause the associated log record to be dropped.
  Add the number of fractional seconds to the log file name to
  avoid this.

* When using small durations and low traffic, we wouldn't expire log
  files until we had processed 10k records.  That's not so bad in
  a production setting, but in the test harness it is problematic.
  We now check for expiration as part of the file size check so
  that we will prune a segment that is at its time limit.

I don't expect either of these conditions to crop up and matter
in a production setting.

I've added a note to the breaking changes section of the changelog
about the addition of the fractional seconds to the log file name.
I don't expect that to impact anyone in practice either, but I
wanted to call it out as a potential difference in case someone
is using a very precise regex/glob to match the file names.
2024-09-30 12:39:43 -07:00
Wez Furlong 1cc1c703a4 docs: add thread pool tuning functions
These could do with some more exposition and explanation,
but just getting them into the docs is good enough for now
2024-09-24 18:43:53 -07:00
Wez Furlong 40938a9c1b improve proxy connection failure error messages and add counters
Failure to connect to a proxy server will now include more context
about the proxy server and protocol in the error message, and
will bump a counter.

Failure to directly bind a source address for the outgoing connection
will bump a counter.

refs: https://github.com/KumoCorp/kumomta/issues/286
2024-09-20 10:21:58 -07:00
Wez Furlong 70472aadc4 docs: fixup link to hickory resolver options 2024-09-18 16:37:43 -07:00
Wez Furlong 12b3ae51ac fix TSA SuspendTenant rules always set duration to 5 minutes 2024-09-18 09:37:31 -07:00
Wez Furlong bb3a84fff5 provider-summary: make order of C/Q consistent with queue-summary 2024-09-16 18:24:31 -07:00
Wez Furlong 5e1ae20497 Add batching support for log hooks
This really is adding batching support to custom lua delivery
protocol handlers, but the main use case for these today is
to implement log hooks.

The way that it works is that you can specify a `batch_size`
as part of setting up the lua protocol handler.

Then, when it is time to send messages, if the batch_size is
the default of 1, the lua delivery logic will invoke the `send` method
on the connection object returned from the constructor.  This
is the same as the behavior from before this commit.

However, if the batch_size is greater than 1, then the lua delivery
logic will instead attempt to collect up to batch_size messages
that are immediately available from the ready queue, and then pass
those to a new `send_batch` method.

The send_batch method accepts an array of messages; that array will
always have at least one message, and up to batch_size messages,
depending on the throughput and queue size.

If the send_batch method's return value applies equally to all
messages in the batch, so if it indicates that something failed,
that disposition will apply to all messages.

One of the reasons that I'd avoided implementing batching thus far
was that it makes it awkward to resolve persistent/recurring issues
that are due to a single message in that batch.  If the batch is
always retried together then there is a good chance that it will
always fail together.

There's no explicit mitigation for that issue here, but it may
be probablistically mitigated by the jitter that is applied to
messages that transiently fail.  If a batch transiently fails,
each message in that batch will be subject to its own random
jitter which should cause an offending message to be retried
with a different subset of messages next time around.

The integration test included here demonstrates the batching
working with an http log hook implementation.
2024-09-16 18:14:25 -07:00
Mike Hillyer 4b26431879 Add a note on how provider and non provider throttles interact. 2024-09-16 15:08:57 -04:00
Mike Hillyer 2037371793 Fix a couple of minor linter issues before push. 2024-09-16 11:33:09 -04:00
Mike Hillyer 22f3ea4454 Finish update of quickstart tutorial. 2024-09-16 11:30:49 -04:00
Mike Hillyer a643c07aaf Initial updates to quickstart tutorial, fix for shaping.toml regex strings and added a note about suffixes to the traffic shaping documentation. 2024-09-16 11:18:21 -04:00
Wez Furlong 0b01503a1c docs: update for new kcli command and tweaks to http endpoints 2024-09-13 09:11:29 -07:00
Wez Furlong a0d9fd7164 kcli: make bounce-list easier to read by default
Sites with lots of tenants and campaigns would produce an overwhelming
amount of output with the default json output mode.

Let's make json opt-in and default to a human readable output
mode that is more concise.

```console
$ kcli bounce-list
ID                                   REASON REMAIN                   BOUNCED CRITERIA
0d2402cc-2dce-44c8-85f6-a4c056300f55 boingo 4m 31s 150ms 560us 575ns  10,990 domain=hotmail.com
```
2024-09-13 08:52:54 -07:00
Wez Furlong be2eeda1f5 the bounce API endpoint is now always asynchronous
In systems with very large numbers of queues, it will take an
effectively unbounded amount of time to produce the initial
summary of results if we were to wait for the bounce to be
applied to every queue.

Let's adjust the output of the kcli to indicate that it is async,
and update the docs which already suggested that the numbers would
be partial to indicate that you can only really consume the id
from the response.
2024-09-13 08:52:54 -07:00
Mike Hillyer 203a279076 Remove orphaned TODO block. 2024-09-12 14:49:15 -04:00
Mike Hillyer 6e32440e2e Cleanup, add link to reference manual. 2024-09-11 17:37:41 -04:00
Mike Hillyer cbddca008d Add a SuspendTenant example. 2024-09-11 17:32:21 -04:00
Mike Hillyer 94680db046 Update base shaping file as well as shaping documentation to show a setconfig example. 2024-09-11 17:25:08 -04:00
Wez Furlong de462b4fe0 dns-resolver: avoid unicode repr of punycode names
Following on from the previous commit, there were two cases where
we'd pick up the unicode human readable version of a punycode encoded
domain name instead of the retaining the punycode text.

One for the domain_name field, and the other for the synthesized
set of MX hosts that we create when the domain has no explicit
A records in its DNS.

This commit fixes that.
2024-09-11 11:48:06 -07:00
tommairs 09f963d536 update to add Debian 12 2024-09-11 17:13:31 +00:00
Mike Hillyer c610777312 Quick fix of backticks for console example. 2024-09-10 12:05:26 -04:00
Wez Furlong 667d1a91cb docs: fix check-liveness links 2024-09-09 09:50:46 -07:00
Wez Furlong 84cb629c91 docs: fix doc build after tsa page was removed 2024-09-09 06:46:59 -07:00
Mike Hillyer 88fa36cbe0 Remove TSA page 2024-09-07 18:32:08 -04:00
Mike Hillyer c247db63d8 Quick update and format. 2024-09-07 18:30:22 -04:00
Mike Hillyer a0c4f17bef Inital Publish of Updated Traffic Shaping Section. 2024-09-07 18:25:40 -04:00
Wez Furlong 76d8192d8f docs: fmt 2024-09-06 17:17:29 -07:00
Wez Furlong 4fa23e9a7d http injector: add deferred generation
There's big explanation about this in the included docs change.

The TL;DR is: we can now optionally queue the request and generate it
asynchronously wrt. the incoming injection request.

There's also a throttle that can be used to constrain this, because
the asynchronous submission disconnects the injection request from
any kind of back pressure that we'd otherwise have to indicate to
the injector that there might be load related issues.
2024-09-06 10:12:33 -07:00
Wez Furlong 5e833a8642 dns-resolver: randomize the list of hosts at a given pref level
Previously, we would deterministically produce the list of hosts
and use the same thing for each session that we established outbound.
This could result in biasing the outgoing traffic onto a single host
and result in lower overall throughput.

This commit shuffles the set of hosts at a given preference level
to probabalistically distribute the load among them.
2024-09-05 16:40:25 -07:00
Wez Furlong c3c4d12acf http inject: deferred_spool is not a required parameter 2024-09-05 07:33:56 -07:00
Wez Furlong 9b45903d44 http inject: add optional deferred_spool parameter
This can increase injection performance, trading increased risk
of loss of accountability for increased speed.
2024-09-04 14:56:14 -07:00
Mike Hillyer 4a1995e772 Update the shaping files to show a better sample usage, add Intercom to the documentation site. 2024-09-04 16:59:10 -04:00
Wez Furlong 4e04efc497 docs: add docs for new amqprs client 2024-09-03 22:28:50 -07:00
Wez Furlong ce8b8c991e docs: update kcli for new trace params 2024-09-03 22:28:21 -07:00
Wez Furlong b5eb78b72b dkim_sign.lua: make base and domain optional
When splitting the config across multiple files, we should not
raise an error if the base or domain section is missing from
the file that is currently being processed.

Let's also show which file is currently being processed.
2024-09-03 14:54:09 -07:00
Wez Furlong b384fb73a4 kcli trace-smtp-(client|server): improve usage for busy sites
This commit adds a couple of options that make it a bit easier
to make sense of high traffic environments.

It also fixes an issue with displaying timing: previously, if
we'd never seen the official start of a session, we'd never
show a reasonable time delta, and every record for that session
would be reported as `0ns`.

Now we assume that the first record for a session is as good as
the starting time for the session. That allows us to show
some meaningful timing information in the case that we attach
to an in-flight session for which we missing the start.
2024-09-03 06:25:09 -07:00
Wez Furlong 054f1eec15 docs: fix title for the most recent stable release changelog 2024-09-02 14:09:43 -07:00
Wez Furlong 7fe88f34a6 queue: make the default strategy SingletonTimerWheel 2024-09-02 14:08:48 -07:00
Wez Furlong 3ae6ef4223 docs: add some brief notes about what is now in main 2024-09-02 10:52:41 -07:00
Wez Furlong 541b8f28e4 shaping: add provider concept to shaping helper
This enables shaping based on MX hostname and domain name matching
rules.

At a lower level, this is supported via two new options:
additional_connection_limits and additional_message_rate_throttles that
allow specifying arbitrarily scoped named limits and throttles, which
in addition to allowing provider-based rules in the shaping helper,
allow things like global or other more esoteric scoping of constraints.

closes: https://github.com/KumoCorp/kumomta/pull/260
2024-09-02 10:42:15 -07:00
Wez Furlong f7e68070d1 config: introduce ConfigEpoch and policy file monitoring
This commit adds a background task that periodically evaluates
a glob expression that defaults to the recommended configuration
location and filename suffixes, and a set of additional paths
to observe.

Whenever the hash of that combined set of files changes it causes the
ConfigEpoch to increment and broadcast to subscribers that the
configuration has changed in some fashion.

The QueueConfig struct has a new refresh_strategy which can select
between the earlier Ttl based refresh for the queue config, or
the new Epoch refresh.

When the epoch changes, the config refresh task will cause each of
the scheduled queues that is using the Epoch strategy to re-evaluate
the get_queue_config event to update their configuration.

The queues helper sets the refresh strategy to Epoch.

A new HTTP endpoint has been added: it can force a bump in the
current epoch, effectively causing all epoch subscribers to
wake up and perform a refresh.

These changes avoid doing O(number-of-scheduled-queues) get_queue_config
callouts every refresh_interval; instead, the work is performed only
when an appropriate change is detected or triggered.
2024-09-02 10:42:14 -07:00
Wez Furlong 276bf9f8cb docs: update changelog for 2024.09.02-c5476b89 2024-09-02 07:29:27 -07:00
Wez Furlong a42871cb11 docs: update since dev -> 2024.09.02-c5476b89 2024-09-02 07:27:50 -07:00
Wez Furlong a18308a3b2 docs: mention SingletonTimerWheel 2024-09-01 15:38:12 -07:00
Mike Hillyer d261986699 Get rid of linter complaints. 2024-08-26 16:53:53 -04:00
Mike Hillyer ad5b393e55 Update the cluster scaling page. 2024-08-26 16:52:56 -04:00