ASP.NET Core & Web API (50 Qs)•Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)
Background Tasks and Hosted Services with Channels.
senior LevelSystem DesignGolang
In Simple Words:
BackgroundService: Base class implementingIHostedServiceto run long-running background loops.System.Threading.Channels: High-performance, lock-free producer-consumer queue in memory. Web controllers push background tasks (e.g. sending emails, generating reports) into a channel, and aBackgroundServiceconsumes and processes items asynchronously without blocking user requests.