Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Running Kernel Memory as a service in Asp.Net #493

Closed
Robban1980 opened this issue May 16, 2024 · 1 comment
Closed

[Question] Running Kernel Memory as a service in Asp.Net #493

Robban1980 opened this issue May 16, 2024 · 1 comment
Labels
completed question Further information is requested

Comments

@Robban1980
Copy link

Context / Scenario

I am looking at running Kernel Memory as a service in Asp.Net API.

Question

I took a look at the Service.AspNetCore code and saw that IKernelMemory is registered as a singleton. With an API i was wondering why we should register IKernelMemory as a singleton instead of as a scoped service?

@Robban1980 Robban1980 added the question Further information is requested label May 16, 2024
@dluc
Copy link
Collaborator

dluc commented May 16, 2024

The recommended deployment uses asynchronous queues to execute tasks in the background, to avoid blocking user requests and to deal with long running jobs.

For example, when uploading a file it might take seconds/minutes to process, depending on the pipeline in use, depending on external services bandwidth, and in case of transient errors requiring the service to retry.

To avoid blocking TCP/HTTP requests while documents are processed, the ingestion is designed to run as a task outside the scope of a HTTP request. Using a singleton allows KM components to work. It's also perfectly safe to use KM as a singleton.

On the other hand, if for some reason you cannot use singletons, then I would recommend configuring KM in Serverless mode. Everything will run synchronously, blocking HTTP requests while ingestion is running, and once a request is complete the KM instance can be disposed.

@dluc dluc added the completed label May 18, 2024
@dluc dluc closed this as completed May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants