Skip to content

Handling long-running operations #135

@Hulkstance

Description

@Hulkstance

If a message takes 5 seconds to be processed as it involves some database operations, it shouldn't slow the server processing pipeline overall as that's going to cause backpressure. In such situations I really wonder what @Marfusios you would do:

  1. Making server message processing run in parallel
public static IDisposable SubscribeAsync<T>(this IObservable<T> source, Func<T, Task> onNext) =>
    source
        .Select(item => Observable.FromAsync(() => onNext(item)))
        .Merge()
        .Subscribe();

instead of

public static IDisposable SubscribeAsync<T>(this IObservable<T> source, Func<T, Task> onNext) =>
    source
        .Select(item => Observable.FromAsync(async () => await onNext(item)))
        .Concat()
        .Subscribe();
  1. Offload the data processors/handlers to a separate thread

What do you think is best? Both solutions are working but I kinda want to know someone else's opinion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions