Skip to content

New "UseOptimizedGreenfieldOptions()" Mode in Bootstrapping #4094

@jeremydmiller

Description

@jeremydmiller

Let's say you're starting a brand new, green field application with Marten & Wolverine and you want to use every little "opt in" flag in Marten that helps your application perform better and scale better as well as have all the robustness things turned on. I've long thought we'd add a single config method that does just that.

From a blog post I was working on anyway, I'm proposing that:

// NOT wedded to the API name here
opts.UseOptimizedGreenfieldOptions();

is the same as this, w/ maybe requiring you to specify to use middle tier timestamps or server side timestamps

var builder = Host.CreateApplicationBuilder();

builder.Services.AddMarten(m =>
{
    // Much more coming...
    m.Connection(builder.Configuration.GetConnectionString("marten"));

    m.Events.AppendMode = EventAppendMode.Quick;
    // or if you care
    // 50% improvement in throughput, less "event skipping"
    m.Events.AppendMode = EventAppendMode.QuickWithServerTimestamps;

    // 100% do this, but be aggressive about using it
    m.Events.UseArchivedStreamPartitioning = true;

    m.Events.EnableAdvancedAsyncTracking = true;
    m.Events.EnableEventSkippingInProjectionsOrSubscriptions = true;
    m.Events.UseIdentityMapForAggregates = true;
    m.Events.UseMandatoryStreamTypeDeclaration = true;
})
// This will remove some runtime overhead from Marten
.UseLightweightSessions()

Ramifications

  • You'd have to use FetchForWriting() for all event appending if you want to use event metadata like the Version or Timestamp in Inline projections -- but you really should anyway
  • LIkewise, the "use identity map for aggregate" option will break people who use that old "AggregateRoot" pattern, but I'm trying to discourage that usage anyway:)
  • The mandatory stream type thing just helps a lot of book keeping later on

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions