-
To put into context, we are using aspnet core for micro service like everybody else in kubernetes and we kinda of running out of memory within the cluster... I'm thinking to put the service api and worker running in same project, thus it will run in the same pod. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Can you illustrate a bit what the worker does? E.g. is it cpu-bound work or IO (like DB, other HTTP-calls), etc. |
Beta Was this translation helpful? Give feedback.
-
in general the worker will
i also see some sample use worker to initiate "async" connection |
Beta Was this translation helpful? Give feedback.
-
make sense, one more question if you don't mind The worker (BackgroundService) have overrides over Connection to the queue and event handler that message received is registered in StartAsync
Is this approach correct? |
Beta Was this translation helpful? Give feedback.
In
StopAsync
you could disconnect from the queue.Otherwise it looks good.
For
ExecuteAsync
-- where basically nothing is to do here, as you also pointed out -- I'd usePeriodicTimer
instead:This avoids the repeated allocation of the task in
Task.Delay
, thus puts less pressure on the GC. Well, here this shouldn't really matter as done only once a minute, but the code is as readable (at least), so that change is just for goodness.Dependin…