-
Notifications
You must be signed in to change notification settings - Fork 145
Description
Current codegen is really well suited for what I would call traditional servers/sustained throughput. So we are eagerly caching a lot of stuff so that the process can hit the ground running as requests start to come in. So in default configuration, this is what happens:
- Process starts up
- DI registrations run (registers all services, handlers, behaviors etc...)
- First reference to
IMediatorwill instantiateContainerMetadatawhich will load all the caching for all messages/handlers - All messages passing through Mediator will be very fast
AOT on the server side makes a lot of sense with serverless workloads where the process is shortlived and we might prefer more lazyness/less caching. I don't have much experience in this area but I assume that we might want the lifecycle to look more like this
- Process starts up
- DI registrations run (registers all services, handlers, behaviors etc...) - we don't know which services we potentially don't need
- 1 HTTP request recieved
- 1 Mediator message dipatching - lazily resolve handlers for this specific message and nothing else
- Process shuts down (after serving response)
We could have an enum on MediatorOptions that looks something like this
enum OptimizationPreference
{
SustainedThroughput,
ColdStart,
}Very unsure about the naming here, tried to think of concepts that are more or less timeless, but I don't think SustainedThroughput makes any sense, heh